![]() |
A local file is a .json file that contains a set of translations for the text strings used in a theme template file. A separate local file is used for every language. Package.json includes all the local dependencies which may be of use or no use and is found in all npm libraries. It can be seen as the heart of any node project. When you require moment.js in your code and pack it with webpack, the bundle size becomes huge because it includes all locale files. To remove all locale files we have to use the IgnorePlugin or ContextReplacementPlugin These are the following ways to prevent moment.js from loading locales with webpack: Table of Content Using IgnorePlugin in index.jsIt is used to exclude certain modules from the final bundled file, reducing the bundle size by ignoring specified files or dependencies. const webpack = require('webpack'); Using ContextReplacementPlugin in index.jsThe ContextReplacementPlugin allows you to override the inferred information i.e. provide a new regular expression (to choose the languages you want to include). let webpack = require("webpack"); |
Reffered: https://www.geeksforgeeks.org
Node.js |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 18 |