/
webpack.config.mjs
executable file
·60 lines (54 loc) · 1.08 KB
/
webpack.config.mjs
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
import path from 'path'
import {
CleanWebpackPlugin
} from 'clean-webpack-plugin'
import Webpack from 'webpack'
import TerserPlugin from 'terser-webpack-plugin'
const {
EnvironmentPlugin,
SourceMapDevToolPlugin
} = Webpack
const srcPath = path.join(path.resolve('./src'), 'js/app.js')
const pubPath = path.join(path.resolve('./pub'), 'assets/js')
export default {
mode: 'production',
entry: {
app: srcPath
},
output: {
path: pubPath,
filename: '[name].js'
},
stats: {
colors: true
},
module: {
rules: [
{
test: /\.js?$/,
use: 'babel-loader',
exclude: /node_modules/
}
]
},
plugins: [
new CleanWebpackPlugin({
verbose: false,
cleanOnceBeforeBuildPatterns: [
pubPath.concat('/*.js'),
pubPath.concat('/*.js.map')
]
}),
new EnvironmentPlugin({ NODE_ENV: 'production' }),
new SourceMapDevToolPlugin({ filename: '[name].js.map' })
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin()
]
},
experiments: {
backCompat: false
}
}