-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
49 lines (48 loc) · 1.39 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
// webpack入口文件,webpack从这里开始构建依赖图
entry: {
main: './src/index.tsx',
},
// 输出文件./dist/bundle.js
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
// webpack只能处理js和json文件。加载别的文件需要loader处理,module就是配置loader的地方。
module: {
rules: [
{
// /\.js$/ 改成 /\.tsx?$/
test: /\.j|tsx$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /.css$/,
use: ['style-loader', 'css-loader']
}
]
},
// 增加扩展选项,让webpack可以识别.ts/tsx文件
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
// webpack加载html文件需要html-webpack-plugin插件处理。
// 启动webpack-dev-server的时候,会把打包好的js文件、css文件、html文件放在内存里。
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
})
],
mode: 'development',
devServer: {
proxy: {
'/api': 'http://localhost:8080',
},
client: {
progress: true
}
}
}