Repository navigation
Expand file tree
/
Copy pathwebpack-data.config.js
More file actions
102 lines (100 loc) · 2.99 KB
/
Copy pathwebpack-data.config.js
File metadata and controls
102 lines (100 loc) · 2.99 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const webpack = require('webpack');
const path = require('path');
const config = {
entry: {
'account-recovery': path.resolve(__dirname, './src/all/webAccessibleResources/js/app/AccountRecovery.js'),
'app': path.resolve(__dirname, './src/all/webAccessibleResources/js/app/App.js'),
'setup': path.resolve(__dirname, './src/all/webAccessibleResources/js/app/Setup.js'),
'recover': path.resolve(__dirname, './src/all/webAccessibleResources/js/app/Recover.js'),
'login': path.resolve(__dirname, './src/all/webAccessibleResources/js/app/Login.js'),
'quickaccess': path.resolve(__dirname, './src/all/webAccessibleResources/js/app/QuickAccess.js')
},
mode: 'production',
plugins: [
new webpack.ProvidePlugin({
// Inject browser polyfill as a global API, and adapt it depending on the environment (MV2/MV3/Windows app).
browser: path.resolve(__dirname, './src/all/common/polyfill/browserPolyfill.js'),
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules[\\/]((?!(passbolt\-styleguide))))/,
loader: "babel-loader",
options: {
presets: ["@babel/react"],
}
},
// Transform SVG as react component
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: [
{
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
cleanupIds: false,
removeTitle: false,
removeDesc: false,
},
},
},
{
name: 'prefixIds',
params: {
prefixIds: false,
prefixClassNames: false
},
},
],
}
}
}
],
}
]
},
optimization: {
splitChunks: {
minSize: 0,
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]((?!(passbolt\-styleguide)).*)[\\/]/,
name: 'vendors',
chunks: 'all'
},
}
},
},
resolve: {
alias: {
'react': path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
},
extensions: ["*", ".js", ".jsx"]
},
output: {
// Set a unique name to ensure the cohabitation of multiple webpack loader on the same page.
chunkLoadingGlobal: 'dataChunkLoadingGlobal',
path: path.resolve(__dirname, './build/all/webAccessibleResources/js/dist'),
pathinfo: true,
filename: '[name].js'
}
};
exports.default = function (env) {
env = env || {};
// Enable debug mode.
if (env && env.debug) {
config.mode = "development";
config.devtool = "inline-source-map";
}
return config;
};