-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.dev.js
49 lines (45 loc) · 1.08 KB
/
webpack.dev.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
const { merge } = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const globby = require('globby');
const path = require('path');
const common = require('./webpack.common');
const buildHtmlWebpackConfigs = async function () {
const demoFiles = await globby(['src/demo/**.html']);
return demoFiles.map((demoFile) => {
const demoFileBase = path.parse(demoFile);
return new HtmlWebpackPlugin({
template: demoFile,
inject: true,
chunks: ['index'],
filename: `${demoFileBase.name}.html`,
})
});
};
module.exports = async function(env) {
return merge(common(env), {
entry: {
index: [
'./src/entry.js',
'./src/demo/preview.js',
'./src/demo/preview.scss',
],
},
mode: 'development',
watch: true,
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
}
]
},
plugins: [
...await buildHtmlWebpackConfigs()
]
});
};