Answer the question
In order to leave comments, you need to log in
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
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.
webpack should build bundles (build if you want). It is no longer needed in production.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question