-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
68 lines (65 loc) · 1.71 KB
/
webpack.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
56
57
58
59
60
61
62
63
64
65
66
67
68
const webpack = require("webpack");
const webpackMerge = require("webpack-merge");
// va chercher le mode de l'environnement dans la commande effectuée
const modeConfig = (env) => require(`./build-utils/webpack.${env}`)(env);
const presetConfig = require("./build-utils/loadPresets");
//environment and presets arguments with their default values are given
module.exports = (
{ mode, presets, psw } = { mode: "production", presets: [] }
) => {
return webpackMerge(
{
mode,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
"babel-loader",
{
loader: "eslint-loader",
},
"stylelint-custom-processor-loader", //for css in js
],
},
{
test: /\.svg$/,
use: ["@svgr/webpack"],
},
{
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "fonts/",
},
},
],
},
],
},
plugins: [
//adds the created bundles between script tags in the output file
new webpack.ProgressPlugin(),
new webpack.DefinePlugin({
__PSW__: JSON.stringify(psw || ""),
}),
],
optimization: {
//creats also a bundle from vendors
splitChunks: {
// include all types of chunks
chunks: "all",
},
},
},
modeConfig(mode)
// presetConfig({
// mode,
// presets
// })
);
};