React开发中的Webpack配置
Webpack配置文件一览
Webpack中配置文件是它的关键,绝大多数配置都在 webpack.config.js
中,主要结构如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18const path = require('path');
module.exports = {
entry: './app.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'my-first-webpack.bundle.js'
},
module: {
rules: [
{ test: /\.txt$/, use: 'raw-loader'}
]
},
plugins: [
new HtmlWebpackPlugin({ template: './src/index.html'})
],
mode: 'development'
};