Configuring webpack to run locally in a user domain via HTTPS

To use the module that I want to integrate into my application (I am developing locally), I need to do two things:
1) Make my application run locally on HTTPS.
2) Run the application with a specific domain.

Both of these things should be fairly lightweight from the Webpack dev server, which I use for local development, but for some reason it does not work as the documentation suggests.

My webpack.config file:

 module.exports = { entry: './app/js/app.js', output: { path:'./app/js/', publicPath: 'https://specialurl.com/assets', filename:'bundle.js' } 

The path I point to was added to my hosts file on my computer, so it should be as valid as localhost by default.

And my package.json file has this as it runs the script for the dev server:

 "scripts": { "start": "webpack-dev-server --progress --colors --https", } 

I made these changes and then restarted with npm starting after saving. The problem is that the server is still not working on https, and when I point my browser to a new link, it just doesn't show anything. All the documentation I found seems like this should work, so I should be missing out on something obvious.

+6
source share
1 answer

I decided! Turns out this is very easy to do with Webpack, as I expected, but the documentation is a bit confusing.

You simply edit the host file to contain the domain you need, and then add the following code to your webpack.config :

  devServer: { host: "localhost.specialurl.com", port: 1234, https: true }, 

Launch npm start and point your browser to https://localhost.specialurl.com:1234/webpack-dev-server and you should be installed :)

+11
source

All Articles