Webpack is also able to handle multiple other tasks:
You can install Webpack globally or locally for each project. Using yarn:
yarn global add webpack webpack-cli
Or using npm:
npm i -g webpack webpack-cli
How to start with Webpack
First of all, to start working with the webpack you need to know the following:
You also need to define the following properties within the module.exports object.
entryhere you need to enter the path to the ./src/index.js file.outputpath: the folder in which the package is created is typically called ./dist or public/main.js. Here the public files of your application will be located.Filename: here will be contained all code.
Next, you need to install loaders – npm special libs – and update the webpack.config.js to add some other files instead of JS.Plugins are almost the same as loaders but under steroids. They can do what downloaders can’t. For example, on top of everything else, Webpack is built on a system of plugins that you use in your configuration file.
Modes of Webpack
The modes ( introduced in version 4) configure the environment in which Webpack will work. The mode can be configured for development (dev) or production (prod). The default mode is production.
less optimized than production;runs faster;doesn’t strip comments;provides deeper error messages and workarounds;makes debugging much easier.
To start the Webpack you can also with npm or yarn:
npm run buildyarn run build or yarn build.
Webpack requires considerable training. But it is a tool well worth learning, considering the amount of time and effort it may save. Webpack doesn’t solve all issues. But it does fix the bundling issue.
Articles you may like:
What is Git and Why Use It – Flatlogic Tech GlossaryHow to Create a Vue Application [Learn the Ropes!]What is PHP – Flatlogic Tech GlossaryWhat is Hosting and Domain Name – Flatlogic Blog
The post What is Webpack? appeared first on Flatlogic Blog.