-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathwebpack.config.js
More file actions
98 lines (95 loc) · 3.13 KB
/
Copy pathwebpack.config.js
File metadata and controls
98 lines (95 loc) · 3.13 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
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const I18nextExtractionPlugin = require("./config/webpack.i18n");
const { buildLessEntries, lessRule, lessMinimizer } = require("./config/webpack.less");
const isDevelopment = process.env.NODE_ENV === "development";
module.exports = {
mode: isDevelopment ? "development" : "production",
entry: () => ({
"api-account-recovery": path.resolve(__dirname, "./src/react-extension/ApiAccountRecovery.entry.js"), // The account recovery application served by the API
"api-app": path.resolve(__dirname, "./src/react-extension/ApiApp.entry.js"), // The passbolt application served by the API
"api-recover": path.resolve(__dirname, "./src/react-extension/ApiRecover.entry.js"), // The recover application served by the API
"api-setup": path.resolve(__dirname, "./src/react-extension/ApiSetup.entry.js"), // The setup application served by the API
"api-triage": path.resolve(__dirname, "./src/react-extension/ApiTriage.entry.js"), // The triage application served by the API
"api-feedback": path.resolve(__dirname, "./src/react-extension/ApiFeedback.entry.js"), // The feedback application served by the API
...buildLessEntries(),
}),
...(isDevelopment && {
devtool: "inline-cheap-module-source-map",
}),
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: "babel-loader",
options: {
presets: ["@babel/react"],
},
},
lessRule,
{ test: /\.json$/, loader: "json-loader" },
// 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,
},
},
],
},
},
},
],
},
],
},
plugins: [
new I18nextExtractionPlugin(),
new CopyPlugin({
patterns: [{ from: path.resolve(__dirname, "./src/locales"), to: path.resolve(__dirname, "./build/locales") }],
}),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "api-vendors",
chunks: "all",
},
},
},
// This is only enabled in production mode
minimizer: ["...", lessMinimizer],
},
resolve: {
extensions: [".js", ".jsx"],
},
output: {
clean: true,
path: path.resolve(__dirname, "build/"),
filename: "js/dist/[name].js",
},
};