This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
51 lines (49 loc) · 1.8 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
const path = require('path');
const ChunkRenamePlugin = require('webpack-chunk-rename-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const production = process.env.NODE_ENV === 'production';
const report = process.argv.includes('--report');
module.exports = {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': path.join(__dirname, './resources/js'),
'@assets': path.join(__dirname, './resources/js/assets'),
'@components': path.join(__dirname, './resources/js/components'),
'@plugins': path.join(__dirname, './resources/js/plugins'),
'@router': path.join(__dirname, './resources/js/router'),
'@store': path.join(__dirname, './resources/js/store'),
'@design': path.join(__dirname, './resources/js/design'),
'@lang': path.join(__dirname, './resources/js/lang'),
'@middleware': path.join(__dirname, './resources/js/middleware'),
'@utils': path.join(__dirname, './resources/js/utils'),
'@views': path.join(__dirname, './resources/js/views'),
'@layouts': path.join(__dirname, './resources/js/views/layouts'),
},
},
plugins: [
...(report ? [new BundleAnalyzerPlugin({ openAnalyzer: true })] : []),
...(production
? [
new CompressionPlugin({
filename: '[path][base].gz',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8,
}),
]
: []),
new ChunkRenamePlugin({
initialChunksWithEntry: true,
'/js/app': 'js/app.js',
'/js/vendor': 'js/vendor.js',
}),
],
output: {
chunkFilename: production
? 'js/chunks/[contenthash:8].chunk.js'
: 'js/chunks/[name].chunk.js',
},
};