N
N
Nikolay Erofeev2016-10-08 16:00:28
JavaScript
Nikolay Erofeev, 2016-10-08 16:00:28

Is webpack good for production?

Good evening. I recently learned about bundling. For example, I collected all the dependencies, launched the server, and can I leave it for production?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim, 2016-10-11
@Mackaybravo

Good afternoon, as mentioned above, the task of webpack is to assemble a file (with styles and js, or just js), which is generally called a " bundle ". To do this, the bundle needs to be assembled (build) using the production config for webpack. The production config usually includes various "things" to optimize the final size of the bundle file, because the smaller the better.
Then you upload the bundle to your server and give it as a regular static file. In this case, after changing the code, you will have to:
a) re-build (build a new bundle)
b) overwrite the file on the
server , in which the main thing is to shake the file as hard as possible).
In the dev config, for example, webpack-dev-server is often used , which allows you to use such a thing as HMR ( hot module replacement ), which in turn allows you to develop very comfortably: you change something in the file, and you immediately have it open the browser window displays the changes (without reloading the page).
Of course, this is not necessary in the prod config.
An example command to make a prod bundle:
The main thing here is -p , as this option tells webpack to do a production build. Also, this command contains a special configuration file (webpack.prod.config.js) and the NODE_ENV variable has the value 'production'
Therefore, it would be more accurate to answer: with webpack, you can build a script file (and, if configured, styles) for production.

S
Sergey, 2016-10-08
Protko @Fesor

webpack should build bundles (build if you want). It is no longer needed in production.

_
_ _, 2016-10-08
@AMar4enko

Nope. Collect packages, give them to Nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question