所以我有以下配置文件可用于webpack-dev-server:
'use strict'
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: [
'./src/app.js'
],
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader'
}
]
},
plugins: [
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
})
],
}
一切正常,但是默认情况下,它似乎在http://localhost:8082上启动实时重装服务器。有没有一种方法可以指定用于实时重载的主机,例如说我有一个定义为https://hotreload.com:3000的自定义域?任何帮助将不胜感激!
答案 0 :(得分:1)
Edit your webpack.config.js
to specify devServer.host
, devServer.port
, and devServer.https
. Using your example specs:
module.exports = {
//...
devServer: {
host: 'hotreload.com',
port: 3000,
https: true,
}
}
答案 1 :(得分:1)
您必须设置devServer.public。如果仅使用网址路径,但显然需要整个网址,那就太好了
devServer: {
public: 'https://www.yoursite.com/',
}