-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
99 lines (93 loc) · 2.62 KB
/
webpack.config.js
File metadata and controls
99 lines (93 loc) · 2.62 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
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin")
const MiniCSSExtractPlugin = require("mini-css-extract-plugin")
const path = require("path")
const OutPutTime = require("./output-time")
let mode = "development",
source_map = "source-map"
if (process.env.NODE_ENV === "production") {
mode = "production"
source_map = "eval"
}
module.exports = {
mode: mode,
/**
* entries for raw js files (source)
*/
entry: {
main: path.resolve(__dirname, 'src/main.js'),
charts: path.resolve(__dirname, 'src/charts.js'),
},
/**
* output folder,
* where [name] === entry[name]/entry[i] from above
*/
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
/**
* devtools controls if and how source maps are generated.
*/
devtool: source_map,
/**
* https://webpack.js.org/configuration/plugins/
*/
plugins: [
new MiniCSSExtractPlugin(),
new OutPutTime()
],
/**
* https://webpack.js.org/configuration/module/#rule
*/
module: {
rules: [
{
test: /\.(sc|c)ss$/i,
/**
* postcss-loader (postcss.config.js),
* css-loader and
* finally we extract css to
* a separate file with MiniCSSExtractPlugin.loader plugin.
* Another option, is to use style-loader to inject inline css into
* our template files but we don't need that approach.
*/
use:[
MiniCSSExtractPlugin.loader,
"css-loader",
/**
* postcss-loader (postcss.config.js)
*/
"postcss-loader",
"sass-loader"
]
},
{
test: /\.js$/i,
exclude: /node_modules/,
/**
* babel-loader (babel.config.js)
*/
use: [
"babel-loader"
]
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
type: "asset"
},
]
},
optimization: {
minimizer: [
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.sharpMinify,
options: {
// Your options for `squoosh`
},
},
}),
],
},
}