forked from xxxxouo/small-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
35 lines (33 loc) · 1.03 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
const path = require('path')//引入内置path方便得到绝对路径
const HtmlWebpackPlugin = require('html-webpack-plugin')//引入模板组件
module.exports = {
mode: 'development',//开发模式
entry: './src/main.tsx',//入口文件地址
output: {
path: path.resolve(__dirname, "./dist"),//出口文件,即打包后的文件存放地址
filename: 'bundle.js' //文件名
},
devServer: {
hot: true
},
devtool: 'cheap-module-source-map',
resolve: {
extensions:['.ts', '.js', '.cjs', '.json','tsx'], //配置文件引入时省略后缀名
alias: {
'@': path.resolve(__dirname, './src')
}
},
module: {
rules: [
{
test: /\.tsx?$/, //匹配规则 以ts结尾的文件
loader: 'ts-loader' //对应文件采用ts-loader进行编译
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './index.html' //使用模板地址
})
],
}