Scenario before configuration:
遠(yuǎn)程服務(wù)器nginx上配置了多域名端口均為80,比如配置另一個(gè)test.com,遠(yuǎn)程機(jī)器ip:10.10.10.1
本地配置host: 10.10.10.1 test.com,瀏覽器里輸入test.com即可打開網(wǎng)站
After configuration, I hope that the website can still be opened by accessing test.com, and that the js file can be automatically refreshed after modifying it
webpack.config.js configuration is as follows:
{
entry: {
test:`/es/test.es`
},
output: {
path: Path.resolve('../', 'build/js/'),
filename: '[name].js'
},
devServer: {
proxy: {
"/build/js/test.js": 'http://test.com/build/js/test.js'
},
contentBase: '../build/js/',
watchContentBase: true,
public:'test.com'
}
}
There is only one sentence configured in package.json
"start": "webpack-dev-server",
But the modified file is not automatically refreshed
After the file is changed, automatic compilation can be performed, but the accessed test.com is not automatically refreshed
Please answer
entry: ['webpack/hot/dev-server', path.resolve(__dirname, './app/main.js')],
這樣定義試試