Webpack dev server to Node/IIS

问题内容:

I made an React App and currently i’m using webpack dev server to host it locally.
I need now to deploy and have this app run as a service in a Windows Server in order to be able to close the Windows Session and still have the app running.

Now, i don’t really know how webpack dev server works… i have worked on NodeJS project and just by running “node {file}” the server was running and with “forever” extension it ran as a service.

How can i make this app run as a service?

The way i host my app locally is by using “npm start” which according to the package.json runs a webpack-dev-server.

package.json (just a part):

  "scripts": {
"start": "webpack-dev-server --hot --open",
"lint": "eslint src"  },

问题评论:

答案:

答案1:

basically your Front end files (if they’ve NOT server side code) are static files (HTML / CSS/ IMAGES/ and so on) .. so if they’re ONLY STATIC FILES and ASSETS . .can be deployed on every server … I USUALLY use WEBPACK DEV-SERVER for developing purpose and then deploy them on IIS ..

Just 2 things:

1 -BE SURE to SET the default page on IIS on  Index.html (via Web.Config)

2 - BE SURE to HAVE INSTALLED IIS REWRITE MODULE (to do a redirect to index.html page)

Hope it helps you …

答案评论:

    
The webpack generates a “bundle.js” as the app itself. This is what confuses me… i don’t have a “point of entry” or something… just a “.js” file. How should i serve it?
– TRDrake
3 hours ago
    
ok .. check if your index.html has a <script src=”bunde.js”></script> ..if so try to deploy the index.html (set it as default page on iis) and laso your bundle.js file .. + assets folder if you have one with images and so on
    
So i tried doing this but i get the same result that when i just run the “index.html” file. It links correctly the “bundle.js” but throws an error inside itself because of “Invalid or unexpected token”. The error message can be seen at: ibb.co/kj38sw ibb.co/dfW6eb If i run this using “webpack-dev-server”, the app launches successfully.
– TRDrake
2 hours ago
    
it looks like a build error of webpack
    
It does. So what would be the difference between running webpack-web-server and running webpack and open the “index.html” with the “bundle.js” generated?
– TRDrake
2 hours ago

答案2:

Serve your files as static pages from your Node/IIS server.

答案评论:

    
It’s my first React app, and my first time with webpack. If i run “webpack”, it generates a “bundle.js” as result. How can i serve that bundle? Or i should not use the bundle?
– TRDrake
3 hours ago

原文地址:

https://stackoverflow.com/questions/47752839/webpack-dev-server-to-node-iis

添加评论

友情链接:蝴蝶教程