Set up webpack to run locally on a custom domain over HTTPS
Solved it! Turns out it's very very easy to do with Webpack as I expected, but the documentation is a little confusing.
You simply edit your host file to contain the domain you want, and then add the following code to your webpack.config
:
devServer: { host: "localhost.specialurl.com", port: 1234, https: true},
Run npm start
and point your browser to https://localhost.specialurl.com:1234/webpack-dev-server and you should be all set :)
To make this work with Hot Module Reloading, set the public
value to undefined
, and then it will use the value in host
.
environment.config.devServer.public = undefinedenvironment.config.devServer.host = 'localhost.example.com'environment.config.devServer.https = { https: true, hot: true, key: fs.readFileSync(path.resolve('ssl/localhost.example.com.key.pem')), cert: fs.readFileSync(path.resolve('ssl/localhost.example.com.cert.pem')),}
This is because of this line, Which ignores the specified host, if public
is defined:https://github.com/webpack/webpack-dev-server/blob/master/lib/utils/createDomain.js#L16