Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  188] [ 3]  / answers: 1 / hits: 36322  / 9 Years ago, thu, july 2, 2015, 12:00:00

In order to use a module I want to integrate into my application (I am developing locally), I have 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 pretty easy with the Webpack dev server I am using for local development, but for some reason it is not working as the documentation suggests.



My webpack.config file is:



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


The path I am pointing to has been added to my hosts file on my computer, so it should be just as valid as the localhost default.



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



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


I made these changes and then I restarted with npm start after saving. The problem is that the server is still not running on https, and when I point my browser to the new link, it just shows nothing. All documentation that I have found makes it seem like this should work, so I must be missing something obvious.


More From » localhost

 Answers
87

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 :)


[#65956] Tuesday, June 30, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleyk

Total Points: 730
Total Questions: 99
Total Answers: 99

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;