forked from passbolt/passbolt_browser_extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.background-page.config.js
55 lines (53 loc) · 1.37 KB
/
webpack.background-page.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const path = require('path');
const TerserPlugin = require("terser-webpack-plugin");
const config = {
entry: {
'index': path.resolve(__dirname, './src/all/background_page/index.js'),
},
mode: 'production',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules[\\/]((?!(passbolt\-styleguide))))/,
loader: "babel-loader",
options: {
presets: ["@babel/react"],
}
}
]
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
splitChunks: {
minSize: 0,
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]((?!(passbolt\-styleguide)).*)[\\/]/,
name: 'vendors',
chunks: 'all'
},
}
},
},
resolve: {extensions: ["*", ".js"], fallback: {crypto: false}},
output: {
// Set a unique name to ensure the cohabitation of multiple webpack loader on the same page.
chunkLoadingGlobal: 'backgroundPageIndexChunkLoadingGlobal',
path: path.resolve(__dirname, './build/all'),
pathinfo: true,
filename: '[name].min.js'
}
};
exports.default = function (env) {
env = env || {};
// Enable debug mode.
if (env.debug) {
config.mode = "development";
config.devtool = "inline-source-map";
config.optimization.minimize = false;
config.optimization.minimizer = [];
}
return config;
};