-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
59 lines (54 loc) · 1.2 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
let HWPConfig = new HtmlWebpackPlugin({
template: __dirname + "/src/index.html",
file: "index.html",
inject: "body"
});
/*
* When creating new page, add its filename to 'pages' array here.
*
* It's assumed that all pages are inside 'views/pages' directory.
*/
let pages = [
'about',
'contacts',
'faq',
];
let entryHtmlPlugins = pages.map(function (entryName) {
return new HtmlWebpackPlugin({
filename: entryName + '.html',
template: __dirname + `/src/views/pages/${entryName}.html`
})
});
let config = {
context: __dirname + '/src',
entry: {
app: './assets/js/main.js',
},
output: {
path: __dirname + '/dist',
filename: 'bundle.js',
},
plugins: [
HWPConfig
].concat(entryHtmlPlugins),
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader','css-loader']
},
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
interpolate: true
}
}
},
]
}
};
module.exports = config;