Do you need it?
What is dependency graph?
Webpack creates a dependency graph for you. This is a mathematical principle in which the dependencies of objects of different origins are connected.
Now, however, you can use CommonJS or ES6 modules to create the above-mentioned dependency graph. Small files are used that define their own needs. The browser that does not support the require () command will use the file after packing by Webpack and will be able to work with it.
There are of course tools like Browserify that solve this problem. How will Webpack be better?
What is Webpack doing?
Why is Webpack better than Grunt, Gulp or Browserify?
Grunt and Gulp are tools for working with files and do not have the ability to create a real dependency graph. Browserify, in turn, is a tool for converting require() to call commands running in the browser. It creates dependency graph only for the source code. Webpack combines these features.
What are the advantages of Webpack?
- Removes unnecessary permanent resources. A huge advantage for CSS users. You use images and CSS in the dist/ folder, which you badly need.
- Easier code sharing. Webpack will create a specific .css file for you that will reduce the .js file size.
- Stable work. You will not be able to accidentally enter the code without the image.
- Webpack will certainly slow you down at first, but when used correctly, it will speed up your work up in the future.
What are the Webpack disadvantages?
It does not make sense to hide that this solution has its drawbacks.
- The documentation is written in a complicated language.
- The source code is difficult to master, especially for beginners.
- Webpack configuration is difficult for non-advanced users. So it’s better to look at ready examples.
- Difficult syntax in the code that occurs throughout the documentation, and does not have many explanations.
What is Dev server?
Dev server is a built-in application for local coding. It allows you to view changes in the code in real time, for free. In the case of large projects, such help is invaluable.
Traditional frontend programming relies only on global variables. CSS rules exist in the global namespace. Their use consists in manually setting the selectors. It is very difficult to not make any mistakes in a case of globally defined rules or images. Dependency graph comes with help in the form of Webpack. Automating this process for a large project can be a huge time saving, even if it requires prior configuration.