


npm install moment reduce the size of the moment.js library, you will need to also add moment-locales-webpack-plugin as a devDependency:.You can then install moment.js to your project and import this into your project: Navigate to the newly created project directory: This will configure a new Angular project with styles set to “CSS” (as opposed to “Sass”, Less", or “Stylus”), no routing, and skipping tests. npx new AngularCustomWebpackConfig -style=css -routing=false -skip-tests.In your terminal window, use the following command: You can use to create a new Angular Project. This tutorial was verified with Angular v10.2.0, v10.0.1, moment.js v2.29.1, and moment-locales-webpack-plugin v1.2.0. Some familiarity with setting up a Angular project.Node.js installed locally, which you can do by following How to Install Node.js and Create a Local Development Environment.To complete this tutorial, you will need: In this article, you will take an existing Angular CLI-generated project and use for a custom webpack configuration. For educational purposes in reducing bundle sizes, this article will continue to use moment.js. However, the current project status suggests that there may be other libraries with modern approaches that may suit your project better depending on your target audience. Note: moment.js is a popular library for handling date and time.

However, there are situations where you will want to add custom webpack functionality.įor the purposes of this article, you will learn how to use the moment.js library and remove unused locales to create a smaller bundle size. The Angular CLI can create a new Angular project and it will handle the webpack configuration.
