-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
78 lines (72 loc) · 1.88 KB
/
Copy pathwebpack.config.js
File metadata and controls
78 lines (72 loc) · 1.88 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const path = require('path')
const fs = require('fs')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const pageEntryPoints = {
pages: [
{
entry: 'index',
entryRef: './view/index/index.js',
output: './index/index.js',
template: './view/index/index.html',
htmlFilename:'index/index.html'
},
{
entry: 'register_user',
entryRef: './view/register_user/register_user.js',
output: './register_user/register_user.js',
template: './view/register_user/register_user.html',
htmlFilename:'register_user/register_user.html'
},
{
entry: 'finish_reservation',
entryRef: './view/finish_reservation/finish_reservation.js',
output: './finish_reservation/finish_reservation.js',
template: './view/finish_reservation/finish_reservation.html',
htmlFilename:'finish_reservation/finish_reservation.html'
},
{
entry: 'reservation',
entryRef: './view/reservation/reservation.js',
output: './reservation/reservation.js',
template: './view/reservation/reservation.html',
htmlFilename:'reservation/reservation.html'
}
],
get entries () {
const entries = Object()
console.log(this)
this.pages.forEach((page) => {
entries[page.entry] = page.entryRef
})
return entries
},
get htmlWebpackPlugins () {
return this.pages.map((page) => {
return new HtmlWebpackPlugin({
filename: page.htmlFilename,
template: page.template,
chunks: [page.entry]
})
})
}
}
module.exports = {
mode: 'development',
entry: pageEntryPoints.entries,
output: {
filename: '[name]/[name].js',
path: path.resolve(__dirname, 'dist'),
clean: true
},
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader',
}
]
},
plugins: [
...pageEntryPoints.htmlWebpackPlugins
]
}