-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
54 lines (52 loc) · 1.33 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
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const isDev = process.env.NODE_ENV !== "production";
module.exports = {
devServer: {
clientLogLevel: "silent",
contentBase: path.join(__dirname, "dist"),
host: "localhost",
hot: true,
port: 8081,
progress: true,
stats: "minimal",
sockPort: 8081,
writeToDisk: true,
},
devtool: isDev ? "cheap-module-source-map" : "source-map",
entry: [
path.resolve(__dirname, "./scripts/main.js"),
path.resolve(__dirname, "./styles/main.scss"),
],
mode: isDev ? "development" : "production",
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
isDev ? "style-loader" : MiniCssExtractPlugin.loader,
{ loader: "css-loader", options: { url: false } },
"postcss-loader",
"sass-loader",
],
},
],
},
output: {
filename: "main.js",
path: path.resolve(__dirname, "dist", "js"),
},
plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: "../css/[name].css",
}),
],
resolve: {
alias: {
"@utilities": path.resolve(__dirname, "scripts/utilities"),
"@modules": path.resolve(__dirname, "scripts/modules"),
},
},
};