-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
76 lines (73 loc) · 1.94 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin') // 它是一个类,先引入它
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const index = new HtmlWebpackPlugin({
template: "./src/index.html",
filename: 'index.html',
chunks: ['index']
})
const GraphicProgramming = new HtmlWebpackPlugin({
template: "./src/html/GraphicProgramming.html",
filename: 'GraphicProgramming.html',
chunks: ['GraphicProgramming']
})
const MindMapping = new HtmlWebpackPlugin({
template: "./src/html/MindMapping.html",
filename: 'MindMapping.html',
chunks: ['MindMapping']
})
const FormWin = new HtmlWebpackPlugin({
template: "./src/html/FormWin.html",
filename: 'FormWin.html',
chunks: ['FormWin']
})
const SetHotkey = new HtmlWebpackPlugin({
template: "./src/html/SetHotkey.html",
filename: 'SetHotkey.html',
chunks: ['SetHotkey']
})
module.exports = {
entry: {
// 各个html对应的ts
index: "./src/index.ts",
GraphicProgramming: "./src/html/GraphicProgramming.ts",
MindMapping: "./src/html/MindMapping.ts",
FormWin: "./src/html/FormWin.ts",
SetHotkey: "./src/html/SetHotkey.ts"
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: "[name].js" //生成好的文件名,叫什么都行
}, //出口
devServer: {
static: {
directory: path.join(__dirname, 'dist') //取代了contentBase
},
open: true,
},
plugins: [
index,
GraphicProgramming,
MindMapping,
FormWin,
SetHotkey,
new CleanWebpackPlugin()
],
resolve: {
"extensions": ['.ts', '.js', '.json']
},
module: {
rules: [
{
test: /\.ts$/,
use: ['ts-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
mode: "development" //打包模式为开发模式
}