-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
74 lines (71 loc) · 1.87 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
const path = require("path");
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const environment = process.env.NODE_ENV || "development";
const port = process.env.PORT || 9000;
module.exports = {
context: path.join(__dirname, "src"),
entry: ["./main.js", "./main.scss"],
target: "web",
mode: environment,
devtool: environment === "development" ? "inline-source-map" : "source-map",
output: {
path: path.join(__dirname, "dist"),
filename: "main.js",
clean: true,
},
module: {
rules: [
{
test: /.s?css$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: "css-loader", options: { sourceMap: true } },
{ loader: "sass-loader", options: { sourceMap: true } },
],
},
{
test: /\.html$/i,
type: "asset/resource",
},
],
},
plugins: [
new CleanWebpackPlugin(),
new MiniCssExtractPlugin(),
new CopyPlugin({
patterns: [
{ from: "./*.html" },
// copy assets to the build
{ from: "./assets/" },
],
}),
],
optimization: {
minimize: environment === "production",
minimizer: [
new HtmlMinimizerPlugin(),
new CssMinimizerPlugin(),
new TerserPlugin({
terserOptions: {
format: {
comments: false,
},
},
extractComments: false,
}),
],
},
devServer: {
contentBase: [path.join(__dirname, "src"), path.join(__dirname, "dist")],
port: port,
host: '0.0.0.0',
hot: true,
inline: true,
liveReload: true
},
};