-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
80 lines (77 loc) · 2.14 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
75
76
77
78
79
80
const path = require('path')
const express = require('express')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const demoPages = [
'CodeMirror-Vue',
'CodeMirror-Knockout',
'Contenteditable-Vue',
'Textarea-Vue',
'Textarea-Knockout',
'Input-Vue',
'Task',
]
const config = {
entry: {
index: path.join(__dirname, 'demo', 'index.js'),
},
output: {
filename: '[name].[contenthash].js',
path: path.join(__dirname, 'docs'),
},
module: {
rules: [
{
test: /\.js$/,
include: [
path.join(__dirname, 'demo'),
path.join(__dirname, 'node_modules', '@syncot'),
path.join(__dirname, 'packages'),
],
loader: 'babel-loader',
},
{
test: /\.css$/,
include: [
path.join(__dirname, 'demo'),
path.join(__dirname, 'node_modules', 'codemirror'),
],
loader: 'style-loader!css-loader',
},
{
test: /\.html$/,
include: [path.join(__dirname, 'demo')],
loader: 'html-loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.join(__dirname, 'demo', 'index.html'),
chunks: ['index'],
}),
new HtmlWebpackPlugin({
filename: '404.html',
template: path.join(__dirname, 'demo', '404.html'),
chunks: [],
}),
],
devServer: {
host: '0.0.0.0',
port: 8023,
before(app) {
app.use('/api/', express.static('./docs/api'))
},
},
}
demoPages.forEach((demoPage) => {
config.entry[demoPage] = path.join(__dirname, 'demo', `${demoPage}.js`)
config.plugins.push(
new HtmlWebpackPlugin({
filename: `${demoPage}.html`,
template: path.join(__dirname, 'demo', `${demoPage}.html`),
chunks: [demoPage],
}),
)
})
module.exports = config