const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = {
mode:'production',
entry: {
main:'./src/index.tsx'
},
output:{
filename: '[name].[hash].js',
path: path.resolve(__dirname, 'dist'),
// 配置打包输出环境,不使用箭头函数
environment: {
arrowFunction: false
}
},
plugins:[
new HtmlWebpackPlugin({template: './src/index.html'}),
new CleanWebpackPlugin({cleanOnceBeforeBuildPatterns: ['**/*', '!static-files*']})
],
module:{
rules:[
{ // 处理 TypeScript文件
test:/\.tsx$/,
use:{
loader:'ts-loader'
},
exclude:/node_modules/
}
]
}
}
output下面的environment用于配置打包环境 其中, arrowFunction用于配置webpack是否使用箭头函数, 默认为true