const join = (modulePath) => path.join(process.cwd(), modulePath);
const port = 3000;
let config = {
entry: {
app: join('app')
},
output: {
filename: '[name].js',
path: join('dist'),
pathinfo: true,
publicPath: `http://localhost:${port}`
},
devServer: {
contentBase: './app',
historyApiFallback: true,
inline: true,
port,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['es2015'],
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(['dist', 'build'], {
root: process.cwd()
}),
new HtmlWebpackPlugin({
template: 'app/index.html',
filename: 'index.html'
})
]
};
module.exports = config;
nginx反向代理配置
server {
listen 80;
server_name www.domain1.com;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /srilanka/ {
proxy_pass http://localhost:3000/;
}
}
主机
127.0.0.1 www.domain1.com
我使用nginx
反向代理+ webpack-dev-server
对于IOS设备,它会抛出错误:
Failed to load resource: Could not connect to the server http://localhost:3000/app.js
PC和Android设备运行正常。
使用IOS设备访问网站应该可以正常工作。
我使用IOS设备safari web检查器找到此错误。
我创建了一个repo,因此您可以轻松地重现此行为 https://github.com/mrdulin/webpack-dev-server