I need to specify the host 0.0.0.0
for webpack-dev-server. Please tell me how I can do it in vue-cli
?
@stranger-ru vue-cli
doesn't have anything to do with webpack-dev-server.
webpack dev server CLI options are listed here: https://webpack.github.io/docs/webpack-dev-server.html#webpack-dev-server-cli
if you're using vuejs's webpack template, you might need to edit build/dev-server.js
file and look up how to set host for express.
For the record, here's the patch that sets up the server to use 0.0.0.0:8000
:
diff --git a/build/dev-server.js b/build/dev-server.js
index 782dc6f..d4d4abe 100644
--- a/build/dev-server.js
+++ b/build/dev-server.js
@@ -62,7 +62,7 @@ app.use(hotMiddleware)
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
-var uri = 'http://localhost:' + port
+var uri = 'http://0.0.0.0:' + port
var _resolve
var readyPromise = new Promise(resolve => {
diff --git a/config/index.js b/config/index.js
index 196da1f..cff719c 100644
--- a/config/index.js
+++ b/config/index.js
@@ -23,7 +23,7 @@ module.exports = {
},
dev: {
env: require('./dev.env'),
- port: 8080,
+ port: 8000,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
@megapctr I think the uri is only used for output and testing. You need config it on the dev server like var server = app.listen(port, '0.0.0.0')
in dev-server.js
You're right, but surprisingly that patch was enough in my case
another way to bind on all interfaces
export HOST=0.0.0.0
npm run dev
Most helpful comment
another way to bind on all interfaces