Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get webpack and iis express to work together?

I have Angular 2 and Webpack 2 starter which run on node by webpack-dev-server, and I what to run it from visual studio with web-api.

The problem is when angular2-webpack-starter run webpack-dev-server on port 3000. and IIS Express run on different port 5000.

This is very important to me because I want to use HMR and reload every time the files are changed.

So, How can be combine them together? run on the same port? or any other solution?

like image 639
Shlomi Levi Avatar asked Oct 29 '16 11:10

Shlomi Levi


People also ask

How do I connect to IIS Express?

Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.

Why IIS Express is not working?

The reason - bad IIS config file. Try deleting the automatically-created IISExpress folder, which is usually located at %userprofile%/Documents , e.g. C:\Users\[you]\Documents\IISExpress . Don't worry, VS should create it again - correctly, this time - once you run your solution again. This worked for me.


1 Answers

I had the same dilemma and solved it just by using the proxy option in the webpack dev server config:

module.exports = {
    devServer: {
        contentBase: './dist', /* output folder */
        proxy: {
            '/api': {                                 /* I had only to track calls to api, change path to one you need*/
                target: 'http://localhost:15536/'     /* specify your correct IIS port here */
            }
        }
    },
/*other configurations here*/
}

After code is in place, just run the VS project and start WebPack Dev server alongside. Now all the calls from the app will be redirected to your ASP.NET server.

Let me know if any questions.

like image 66
nehfi Avatar answered Sep 21 '22 21:09

nehfi