-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
47 lines (46 loc) · 1.17 KB
/
webpack.config.js
File metadata and controls
47 lines (46 loc) · 1.17 KB
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
const path = require('path')
const webpack = require('webpack')
module.exports = {
entry: './src/index.js',
mode: 'development',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
chunkFilename: '[name]-bundle.js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
include: /src/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /\.css$/,
exclude: /(node_modules)/,
include: /src/,
use: ['style-loader', 'css-loader']
}
]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
devServer: {
contentBase: path.join(__dirname, "public/"), //静态服务器地址 默认访问localhost:port会返回index.html文件,或者使用具体地址访问文件
port: 3000,
host: "0.0.0.0",
hot: true,
publicPath: "http://localhost:3000/", // 打包文件可访问路径
inline: true,
historyApiFallback: true // 使用react-router时,所有路由都要返回index.html,否则刷新子路由页面会报错
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
}