-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
46 lines (43 loc) · 1.2 KB
/
webpack.config.js
File metadata and controls
46 lines (43 loc) · 1.2 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
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: [
"webpack-dev-server/client?http://localhost:8888",
"webpack/hot/only-dev-server",
"./index.ts"
],
output: {
filename: 'dompark.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
context: path.resolve(__dirname, 'src'),
devServer: {
port: 8888,
hot: true,
quiet: true,
historyApiFallback: true,
contentBase: path.resolve(__dirname, 'dist'),
// 和上文 output 的“publicPath”值保持一致
publicPath: '/'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [{
test: /\.ts$/,
loader: 'ts-loader'
}]
},
plugins: [
new HtmlWebpackPlugin({
template: "../index.html"
}),
// 开启全局的模块热替换(HMR)
new webpack.HotModuleReplacementPlugin(),
// 当模块热替换(HMR)时在浏览器控制台输出对用户更友好的模块名字信息
new webpack.NamedModulesPlugin(),
]
}