forked from hovinghuang/fe-agorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
49 lines (46 loc) · 1.18 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 webpack = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin')
// console.log('process.env.NODE_ENV=', process.env.NODE_ENV) // 打印环境变量
const config = {
entry: './src/index.ts', // 打包入口地址
output: {
filename: 'bundle.js', // 输出文件名
path: path.join(__dirname, 'dist'), // 输出文件目录
clean: true,
},
target: 'web',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/, //匹配所有的 css 文件
use: ['style-loader', 'css-loader'] // use: 对应的 Loader 名称
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
devServer: {
static: './dist',
hot: true,
historyApiFallback: true,
compress: true
},
plugins:[ // 配置插件
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new webpack.HotModuleReplacementPlugin()
]
}
module.exports = (env, argv) => {
console.log('argv.mode=',argv.mode) // 打印 mode(模式) 值
// 这里可以通过不同的模式修改 config 配置
return config;
}