-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.js
89 lines (86 loc) · 2.19 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
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
const path = require("path");
const { VueLoaderPlugin } = require("vue-loader");
const TerserPlugin = require("terser-webpack-plugin");
let optimization = {
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: {
reserved: ["$", "exports", "require"],
},
output: {
comments: false,
},
},
extractComments: false,
parallel: true,
}),
],
};
module.exports = (env) => {
const isProd = env.production ? JSON.parse(env.production) : false;
return {
mode: isProd ? "production" : "development",
devtool: isProd ? "source-map" : "eval-source-map",
entry: path.resolve(__dirname, "src/index.js"),
output: {
path: path.resolve(__dirname, "./dist"),
publicPath: "/dist/",
filename: "[name].js",
},
module: {
rules: [
{
test: /\.(css|sass|scss)$/,
include: [path.resolve(__dirname, "./src")],
use: [
"vue-style-loader",
{
loader: "css-loader",
options: {
esModule: false,
},
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
parser: "postcss-scss",
},
},
},
{
loader: "sass-loader",
options: {
implementation: require("sass"),
},
},
],
},
{
test: /\.vue$/,
include: [path.resolve(__dirname, "./src")],
use: ["vue-loader"],
},
{
test: /\.js$/,
include: [path.resolve(__dirname, "./src")],
use: ["babel-loader"],
},
{
test: /\.(jpg)$/,
use: ["file-loader"],
},
],
},
plugins: [new VueLoaderPlugin()],
optimization: isProd ? optimization : {},
devServer: {
hot: true,
stats: "minimal",
contentBase: path.resolve(__dirname),
overlay: true,
historyApiFallback: true, // This is needed so webpack dev server falls back to index.html when visiting other routes
},
};
};