diff --git a/README.md b/README.md index f3f0789..3988282 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ ddev browsersync ``` The new `ddev browsersync` global command runs browsersync inside the web container and provides a -link ("External") to the browsersync-update URL. Use the URL in the output that says something like "External: ". +link ("External") to the browsersync-update URL. Use the URL in the output that says something like "External: ". ## What does this add-on do and add? @@ -83,12 +83,16 @@ Demo: - Update `webpack.mix.js` ```js +// Use the HOSTNAME provided by DDEV +let url = process.env.DDEV_HOSTNAME; + mix.js('resources/js/app.js', 'public/js') .postCss('resources/css/app.css', 'public/css', [ // ]) .browserSync({ proxy: "localhost", + host: url, open: false, ui: false }); @@ -103,11 +107,11 @@ ddev exec npm run watch [Browsersync] Access URLs: --------------------------------------------------- Local: http://localhost:3000 - External: http://172.28.0.9:3000 + External: http://browsersync-demo.ddev.site:3000 --------------------------------------------------- ``` -- Browsersync will be running at `https://172.28.0.9:3000` +- Browsersync will be running at `https://browsersync-demo.ddev.site:3000` ## TODO diff --git a/browser-sync.js b/browser-sync.js index ddb9119..feb4951 100644 --- a/browser-sync.js +++ b/browser-sync.js @@ -1,6 +1,7 @@ // #ddev-generated let docroot = process.env.DDEV_DOCROOT; let filesdir = process.env.DDEV_FILES_DIR; +let url = process.env.DDEV_HOSTNAME; if (filesdir === "") { filesdir = null @@ -15,5 +16,6 @@ module.exports = { server: false, proxy: { target: "localhost" - } + }, + host: url, }