Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
30 Days Of Javascript | 34,611 | 21 hours ago | 1 | January 25, 2022 | 231 | JavaScript | ||||
30 days of JavaScript programming challenge is a step-by-step guide to learn JavaScript programming language in 30 days. This challenge may take more than 100 days, please just follow your own pace. | ||||||||||
Angular Cli | 26,015 | 118,203 | 13,283 | 21 hours ago | 614 | September 21, 2022 | 214 | mit | TypeScript | |
CLI tool for Angular | ||||||||||
Nx | 17,014 | 126 | 264 | 21 hours ago | 846 | September 23, 2022 | 702 | mit | TypeScript | |
Smart, Fast and Extensible Build System | ||||||||||
Codesandbox Client | 12,285 | 46 | 16 | a day ago | 26 | March 11, 2021 | 366 | other | JavaScript | |
An online IDE for rapid web development | ||||||||||
Clients | 5,767 | 21 hours ago | 515 | other | TypeScript | |||||
Bitwarden client applications (web, browser extension, desktop, and cli) | ||||||||||
Angular Ngrx Material Starter | 2,653 | a year ago | 40 | mit | TypeScript | |||||
Angular, NgRx, Angular CLI & Angular Material Starter Project | ||||||||||
Angular Meteor | 2,383 | 269 | 5 | a year ago | 22 | October 16, 2017 | 22 | mit | Dockerfile | |
Angular and Meteor - The perfect stack | ||||||||||
Sb Admin Bs4 Angular 8 | 1,940 | 10 days ago | 67 | other | HTML | |||||
Simple Dashboard Admin App built using Angular 8 and Bootstrap 4 | ||||||||||
Generator Ngx Rocket | 1,473 | 2 | 1 | 4 months ago | 52 | December 15, 2021 | 37 | mit | TypeScript | |
:rocket: Extensible Angular 14+ enterprise-grade project generator | ||||||||||
Angular Eslint | 1,391 | 82 | 2 days ago | 378 | July 09, 2022 | 70 | mit | TypeScript | ||
:sparkles: Monorepo for all the tooling related to using ESLint with Angular |
Extend the Angular CLI's default build behavior without ejecting:
Big thanks to Rob Wormald and David Herges!
ng update ngx-build-plus --force
single-bundle
now defaults to false
to align with the CLI's default behavior.keepPolyfills
and keepStyles
default to true to avoid misunderstandings.ng build --single-bundle
: Puts everything reachable from the main entry point into one bundle. Polyfills, scripts, and styles stay in their own bundles as the consuming application might have its own versions of these.ng add ngx-build-plus
ng g ngx-build-plus:wc-polyfill
: Adds webcomponent polyfills to your appng g ngx-build-plus:externals
: Updates your app to use webpack externals (see example at the end)This shows a minimal example for getting started. It uses a minimal partial webpack configuration that is merged into the CLI's one. Representative for all possible custom webpack configurations, the used one just leverages the DefinePlugin
to create a global VERSION
constant during the build.
Please find the example shown here in the sample application in the folder projects/getting-started
.
Create a new Angular project with the CLI
Add ngx-build-plus: ng add ngx-build-plus
Note: If you want to add it to specific sub project in your projects
folder, use the --project
switch to point to it: ng add ngx-build-plus --project getting-started
Remark: This step installs the package via npm and updates your angular.json so that your project uses custom builders for ng serve
and ng build
.
Add a file webpack.partial.js
to the root of your (sub-)project:
const webpack = require('webpack');
module.exports = {
plugins: [
new webpack.DefinePlugin({
"VERSION": JSON.stringify("4711")
})
]
}
Use the global variable VERSION in your app.component.ts
:
import { Component } from '@angular/core';
declare const VERSION: string;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Version: ' + VERSION;
}
Start your application with the --extra-webpack-config
switch pointing to your partial webpack config:
ng serve --extra-webpack-config webpack.partial.js -o
If your project is a CLI based sub project, use the --project
switch too:
ng serve --project getting-started -o --extra-webpack-config webpack.partial.js
Hint: Consider creating a npm script for this command.
Make sure that the VERSION provided by your webpack config is displayed.
While ngx-build-plus
can be used in every Angular configuration, it also comes with some schematics automating some scenarios for Angular Elements. More information about can be found here.
Plugins allow you to provide some custom code that modifies your webpack configuration. In addition to that, they also provide a pre- and a post-hook for tasks that need to take happen before and after bundling. This is an example for an plugin:
export default {
pre(options) {
console.debug('pre');
},
config(cfg) {
console.debug('config');
return cfg;
},
post(options) {
console.debug('post');
}
}
As this plugin is written with TypeScript you need to compile it.
The config
method works like a configHook
(see above).
To use a plugin, point to it's JavaScript representation (not the TypeScript file) using the --plugin
switch:
ng build --plugin ~dist\out-tsc\hook\plugin
The prefix ~
points to the current directory. Without this prefix, ngx-build-plus assumes that the plugin is an installed node_module
.
You can also use plugins to implement different merging strategies. The following plugin demonstrates this:
var merge = require('webpack-merge');
var webpack = require('webpack');
exports.default = {
config: function(cfg) {
const strategy = merge.strategy({
'plugins': 'prepend'
});
return strategy (cfg, {
plugins: [
new webpack.DefinePlugin({
"VERSION": JSON.stringify("4711")
})
]
});
}
}
To execute this, use the following command:
ng build --plugin ~my-plugin.js
One more time, the ~
tells ngx-build-plus that the plugin is not an installed node_module but a local file.
This shows another example for using ngx-build-plus
. It uses a custom webpack configuration to define some dependencies of an Angular Element as external which can be loaded separately into the browser and shared among several bundles.
If you are not interested into this very use case, skip this section.
The result of this description can be found in the repository's sample
directory.
Create a new Angular CLI based project and install @angular/elements
as well as @webcomponents/custom-elements
which provides needed polyfills:
npm i @angular/elements --save
Expose a component as an Custom Element:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Injector } from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule
],
declarations: [
AppComponent
],
providers: [],
bootstrap: [],
entryComponents:[AppComponent]
})
export class AppModule {
constructor(private injector: Injector) {
}
ngDoBootstrap() {
const elm = createCustomElement(AppComponent, { injector: this.injector });
customElements.define('custom-element', elm);
}
}
Install ngx-build-plus
:
When using Angular >= 7 and CLI >= 7, you can simply use ng add
for installing ngx-build-plus
:
ng add ngx-build-plus
If you are using a monorepo, mention the project you want to install ngx-build-plus for:
ng add ngx-build-plus --project myProject
Add polyfills:
ng g ngx-build-plus:wc-polyfill --project myProject
Execute the externals schematic:
ng g ngx-build-plus:externals --project myProject
This creates a partial webpack config in your project's root:
module.exports = {
"externals": {
"rxjs": "rxjs",
"@angular/core": "ng.core",
"@angular/common": "ng.common",
"@angular/platform-browser": "ng.platformBrowser",
"@angular/elements": "ng.elements"
}
}
Build your application. You can use the npm script created by the above mentioned schematic:
npm run build:myProject:externals
Angular will now be compiled into a scripts.js
and can be reused amongs several seperately compiled bundles. Your code is in the main bundle which is quite tiny b/c it does not contain Angular.
Further information about this can be found in my blog here.