This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
68 lines (66 loc) · 1.54 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require("path");
const webpack = require("webpack");
const utils = require("./utils");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const entry = {
vendor: ["lodash"],
app: "./src/main.js"
};
module.exports = {
mode: "production",
entry: utils.generateEntry(entry),
devtool: "#source-map",
output: {
filename: "[name].[chunkhash:6].js",
path: path.resolve(__dirname, "dist")
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
}
]
},
plugins: [
// clean dist folder
new CleanWebpackPlugin(["dist"]),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, "./static"),
to: "static",
ignore: [".*"]
}
]),
// specify the HTML template file
// generator HtmlWebpackPlugin instance
...utils.pluginInstance()
],
optimization: {
// compress files
minimize: true,
// split vendor js into its own file
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "all"
}
}
}
}
};