What is the functionality of angular-cli@webpack?

After working with angular-cli using systemJS, I have become comfortable with the build process, test cases, and component interaction.

Recently, I made the switch from angular-cli to angular-cli@webpack.

However, I am now facing confusion on a few points:

  1. Can you explain how the webpack build process works?
  2. How do I go about installing third-party libraries like lodash, ng2-bootstrap, etc. with this webpack configuration since I do not see a webpack.config.ts file?
  3. Why can't I see any bundle containing JS files of my application?
  4. All I can see are TypeScript files for my application. Why is that?

Thank you in advance for your help.

Answer №1

  1. Executing the command ng build will compile all files and store the output in the Dist folder
  2. To include an external dependency, use
    npm install 'external-dependency'
    and then import it into the necessary files (including app.module.ts)
  3. Prior to step 1, make sure to run ng build
  4. Refer to step 1 for further details

Answer №2

  1. webpack processes the entry point and generates the desired output. Here's an example:

     entry: {
            'app': './main.ts'// your entry point
     }, 
    output: {
       path: helpers.root('dist'),
       filename: 'bundle.js' // your build file
    }
    
  2. Simply install dependencies with npm and require them in your project. Webpack will handle bundling them into your build.

    Example

    npm install lodash

And in your project:

require("lodash")
  1. When you use ng-serve to run the application, it serves from memory without building physical files, which is why you don't see any files.
  2. If you use ng-build instead of ng-serve, physical files will be built in the dist folder and become visible.

Learn more about webpack, it's amazing!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Dropdown with grouped options in Angular PrimeNG - displaying data other than the default label/value pair

Hello there, I've encountered some difficulties with the dropdown menu, specifically when it comes to organizing by groups. Initially, I faced challenges understanding the specific format required for the array used in options to populate the dropdow ...

Developing the latest version of ngx-charts

I'm currently working on adding a personalized feature to ngx-charts that I would like to include in a release version. I was successful in implementing it using the standard src directory, but now I want to build a release version for potential distr ...

Getting data before the Router is loaded following authentication with Angular 2+ - A comprehensive guide

I'm hoping this isn't a repeat. Within my login component, I have a feature that allows users to log in, which calls a service and retrieves a Token. Upon successful login, the token is saved to localStorage. Subsequently, I use the getUserData ...

Adding a Key Value pair to every object within an Array using TypeScript

I have two arrays - one contains dates and the other contains objects. My goal is to include the dates as a key value pair in each object, like this: {"Date": "10-12-18"}. dates: ["10-12-18", "10-13-18", 10-14-18"] data: [ {"name":"One", "age": "4"} ...

Angular8 Material Grid displaying headers and tiles, experiencing slight resizing issue with mat-grid-tile content

Exploring Angular8 Material: Grid Layout with Headers and Tiles Currently, I am delving into the workings of the grid system within Angular Material. I am dynamically fetching components and organizing them within a grid. While the grid list and tiles are ...

How can one correctly log out of an Angular application that is integrated with Firebase Authentication and Firestore?

How can I efficiently sign out of an Angular application that uses Firebase Authentication and Firestore? Although I can successfully sign in with Google authentication, signing out poses some challenges. My ultimate goal is to ensure that when a user cli ...

Angular 5 combined with Electron to create a dynamic user interface with a generated Table

I am working on an Angular Pipe: import {Pipe, PipeTransform} from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import * as Remarkable from 'remarkable'; import * as toc from 'markdown-toc&a ...

Using Angular, Typescript, and ngxs to manage state observables, one may wonder what exactly a variable ending with an exclamation mark (!) signifies. An example of this can be seen in the following code snippet:

Within my TS file, a declaration is present: import { Select } from '@ngxs/store'; @Injectable() export class someService { @Select(someSELECTOR) varName$!: Observable<someType[]>; elements$ = this.varName$.pipe( map(elements => e ...

POSTMAN - error when making a post request with the message "The media type 'application/json' is not compatible with this resource."

Snippet of Web API code: [HttpPost] [ODataRoute("GetCMMAutoForLoggedInUser")] public IHttpActionResult GetCMMAutoForLoggedInUser(CMMPermissionRequest request) { var data = this.CommonDomain.GetCMMAutoForLoggedInUser(request); return Ok(data); } ...

Configuring the correct loader in Webpack for Next JS is crucial for optimal performance

I'm encountering an issue while trying to load an HTML file with Next JS and html-loader. The error message I'm seeing is: Module parse failed: Unexpected token (2:2) You may need an appropriate loader to handle this file type, currently no loade ...

Divide a string using multiple delimiters just one time

Having trouble splitting a string with various delimiters just once? It can be tricky! For instance: test/date-2020-02-10Xinfo My goal is to create an array like this: [test,Date,2020-02-10,info] I've experimented with different approaches, such ...

Strange problem encountered when transferring data to and from API using Typescript and Prisma

I'm encountering a strange issue that I can't quite pinpoint. It could be related to mysql, prisma, typescript, or nextjs. I created the following model to display all product categories and add them to the database. Prisma Model: model Product ...

The best practices for utilizing ES6 Modules syntax in TypeScript files within a NextJS environment

The issue appears to be trapped in a loop: package.json is missing type: "module". This results in an error when trying to use modules in TypeScript files: An error occurred while running the seed command: /Users/me/code/me/prisma-learning/grap ...

Troubleshooting error messages with Angular 2 HttpClient response payload

Currently, I am implementing the latest version (4.3) of HttpClient in angular to handle data POST requests to my backend server: this.httpClient.post<View>(`/path`, data).subscribe( (view: View) => console.log("Success"), (error: HttpErrorRe ...

What is the best way to retrieve a nested data type?

I am working with an interface named IFoo interface IFoo { name: string; version: number; init: (arg1: string, arg2: number) => Promise<string[]>; } I am interested in the type of init. Is there a way to extract it so that I can use this i ...

Importing modules that export other modules in Typescript

I am facing an issue with two modules and two classes. ModuleA, ModuleB, ClassA, and ClassB are defined as follows: export class ClassA { } export class ClassB { } The modules are structured like this: export * from './ClassA'; export module ...

What is the process for creating a Deep Copy of an object in Angular?

I have a specific entity class defined as follows: export class Contact { id: number; firstName: string; lastName: string; constructor(id?, firstName?, lastName?) { this.id = id; this.firstName = firstName; this.lastName = lastName; ...

Overlap occurs when Angular Material 2 cards are used in conjunction with flex-layout

I'm currently working on implementing Angular Material 2 cards with flex-layout to dynamically change the number of columns displayed as the browser is resized. My goal is to achieve a layout similar to how Google Keep works. <div *ngIf="condition ...

React dynamic table

I've been experimenting with creating a dynamic table in React that allows users to add and delete rows. I need the data entered by the user to be saved, possibly using in-state management so that I can work with it later. Essentially, I'm looki ...

Oops! Looks like we encountered a problem: "Uncaught ReferenceError: process is not

As I work on my project utilizing angular 6 with Spring-boot, I have encountered an error that I am struggling to resolve. Specifically, the error message reads: Uncaught ReferenceError: process is not defined at Object../node_modules/util/util.js (ut ...