2

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"  },

2 Answers 2

2

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 ...

Sign up to request clarification or add additional context in comments.

7 Comments

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?
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.
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?
i think the difference is the builiding ...cause the dev use the dev SETTINGS .. other build use the prod mode
|
0

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

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.