-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
61 lines (59 loc) · 2.07 KB
/
Copy pathwebpack.common.js
File metadata and controls
61 lines (59 loc) · 2.07 KB
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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackHarddiskPlugin = require("html-webpack-harddisk-plugin");
module.exports = {
entry: {
main: "./src/js/index.js",
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
clean: true,
assetModuleFilename: "assets/img/[name][ext][query]", // without this assets used in js/css will go to main dir
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
type: "asset",
},
],
},
plugins: [
//https://webpack.js.org/plugins/html-webpack-plugin/
//for updating script links in html - not needed when there is not much to update and can be done manually
new HtmlWebpackPlugin({
// title: "Production",
filename: "index.html",
alwaysWriteToDisk: true,
template: "src/index.html",
}),
new HtmlWebpackPlugin({
filename: "about.html",
alwaysWriteToDisk: true,
template: "src/about.html",
}),
new HtmlWebpackPlugin({
filename: "contact.html",
alwaysWriteToDisk: true,
template: "src/contact.html",
}),
new HtmlWebpackPlugin({
filename: "page_temp.html",
alwaysWriteToDisk: true,
template: "src/page_temp.html",
}),
new HtmlWebpackHarddiskPlugin(), //HtmlWebpackPlugin plugin to refresh html on change with dev server. Needs "alwaysWriteToDisk: true" option in HtmlWebpackPlugin config for every file in oder to work
new MiniCssExtractPlugin(),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "src", "assets"),
to: "./assets",
},
],
}),
],
};