-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.prod.js
48 lines (42 loc) · 1.2 KB
/
webpack.prod.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
import { merge } from 'webpack-merge';
import common from './webpack.common.js';
import HtmlWebPackPlugin from 'html-webpack-plugin';
import path from 'path';
import { fileURLToPath } from 'url';
import CopyWebpackPlugin from 'copy-webpack-plugin';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const htmlPlugin = new HtmlWebPackPlugin({
template: './src/index.html',
filename: '../index.html',
favicon: 'src/favicon.png'
});
const copyPlugin = new CopyWebpackPlugin({
patterns: [
{ from: "docs/img", to: "img" },
{ from: "public", to: "../" },
],
});
export default merge(common, {
mode: 'production',
devtool: 'source-map',
output: {
asyncChunks: true,
publicPath: '/static/',
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist/static'),
clean: true,
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "all"
}
}
}
},
plugins: [htmlPlugin, copyPlugin]
});