This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.common.config.js
89 lines (88 loc) · 2.27 KB
/
webpack.common.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 webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
entry: {
index: "./src/index/index.js",
about: "./src/about/about.js",
projects: "./src/projects/projects.js",
features: "./src/features/features.js",
getStarted: "./src/get-started/get-started.js",
},
output: {
filename: "js/[name].[hash].bundle.js",
chunkFilename: "[name].[hash].bundle.js",
path: path.resolve(__dirname, "dist/"),
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
plugins: ["@babel/plugin-syntax-dynamic-import"],
},
},
{
loader: "eslint-loader",
options: {
enforce: "pre",
emitWarning: true,
},
},
],
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.(jpg|svg|png)$/,
use: [
{
loader: "file-loader",
options: {
name: "[path][name].[ext]",
context: "src",
},
},
],
},
],
},
plugins: [
new CleanWebpackPlugin(["dist"]),
new HtmlWebpackPlugin({
filename: "index.html",
template: "src/index/index.html",
chunks: ["index"],
}),
new HtmlWebpackPlugin({
filename: "about.html",
template: "src/about/about.html",
chunks: ["about"],
}),
new HtmlWebpackPlugin({
filename: "projects.html",
template: "src/projects/projects.html",
chunks: ["projects"],
}),
new HtmlWebpackPlugin({
filename: "features.html",
template: "src/features/features.html",
chunks: ["features"],
}),
new HtmlWebpackPlugin({
filename: "get-started.html",
template: "src/get-started/get-started.html",
chunks: ["getStarted"],
}),
new CopyWebpackPlugin([{ from: "src/assets", to: "assets" }]),
],
};