Skip to content

Instantly share code, notes, and snippets.

@perry-mitchell
Last active September 19, 2019 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perry-mitchell/977ed506907ac8b1be3249f6668462db to your computer and use it in GitHub Desktop.
Save perry-mitchell/977ed506907ac8b1be3249f6668462db to your computer and use it in GitHub Desktop.
const config = {
devtool: false,
entry: path.resolve(__dirname, `source/entry_${entryType}/main_init.js`),
module: {
rules: [
{
test: /\.js$/,
use: "babel-loader"
},
{
test: /\.html$/,
use: [{
loader: "html-loader",
options: {
minifyJS: {
compress: {
collapse_vars: false,
dead_code: false,
hoist_props: false,
unused: false
}
},
minimize: true,
removeAttributeQuotes: false,
removeComments: false
}
}]
}
]
},
node: {
setImmediate: false
},
performance: {
hints: "error",
maxAssetSize: MAX_ASSET_SIZE,
maxEntrypointSize: MAX_ASSET_SIZE
},
output: {
filename: buildProductionBundles ?
`${moduleHash}.es5.js` :
`${entryType}.${environment}.js`,
path: path.resolve(__dirname, "./dist")
},
plugins: [
new BannerPlugin(
[
"Kiosked CFE library",
"@copyright Kiosked Ltd. - All rights reserved",
"@see https://kiosked.com"
].join("\n")
),
new DefinePlugin({
__ENTRY__: JSON.stringify(entryType),
__ENV__: JSON.stringify(environment),
__DEV__: ["testing", "development"].indexOf(environment) >= 0,
__TESTING__: environment === "testing"
}),
new ProvidePlugin({
Promise: require.resolve("native-promise-only"),
Symbol: require.resolve("es6-symbol")
}),
...extraPlugins
],
resolve: {
extensions: [".js", ".json", ".html"],
symlinks: true,
modules: [
path.resolve(__dirname, "./source"),
path.resolve(__dirname, "node_modules")
]
}
};
if (nodeEnv === "production") {
config.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: 2,
terserOptions: {
ecma: 5,
extractComments: {
banner: "Test Banner",
condition: /.*/
},
output: {
comments: /@copyright.+My Company/i
}
}
})
]
};
}
return config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment