-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.demo.js
63 lines (57 loc) · 1.38 KB
/
webpack.config.demo.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const distPath = path.resolve(__dirname, 'dist', 'demo');
const entry = {
index: './demo/index.tsx',
todolistapp: './demo/todo-list-app.tsx',
countersapp: './demo/counters-app.tsx',
twoapps: './demo/twoapps.tsx',
shopapp: './demo/shop-app.tsx',
starseditor: './demo/stars-editor/index.tsx',
};
module.exports = {
entry,
output: {
filename: '[name].bundle.js',
path: distPath,
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
devServer: {
static: distPath,
compress: true,
port: 4000,
},
plugins: [
...Object.keys(entry).map(entryName => {
return new HtmlWebpackPlugin({
inject: false,
template: './demo/index.html',
filename: `${entryName}.html`,
chunks: [entryName],
});
}),
new CopyPlugin({
patterns: [
{ from: './demo/index.css', to: path.resolve(distPath, 'index.css') },
],
}),
],
// plugins: [new HtmlWebpackPlugin({ template: path.resolve(distPath, 'index.html') })],
};