mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 20:02:40 +08:00
When using the `application` builder, a new `loader` option is now available for use. The option allows a project to define the type of loader to use with a specified file extension. A file with the defined extension can then used within the application code via an import statement or dynamic import expression, for instance. The available loaders that can be used are: * `text` - inlines the content as a string * `binary` - inlines the content as a Uint8Array * `file` - emits the file and provides the runtime location of the file * `empty` - considers the content to be empty and will not include it in bundles The loader option is an object-based option with the keys used to define the file extension and the values used to define the loader type. An example to inline the content of SVG files into the bundled application would be as follows: ``` loader: { ".svg": "text" } ``` An SVG file can then be imported: ``` import contents from './some-file.svg'; ``` Additionally, TypeScript needs to be aware of the module type for the import to prevent type-checking errors during the build. This can be accomplished with an additional type definition file within the application source code (`src/types.d.ts`, for example) with the following or similar content: ``` declare module "*.svg" { const content: string; export default content; } ``` The default project configuration is already setup to use any type definition files present in the project source directories. If the TypeScript configuration for the project has been altered, the tsconfig may need to be adjusted to reference this newly added type definition file.
@angular-devkit/build-angular
This package contains Architect builders used to build and test Angular applications and libraries.
Builders
Name | Description |
---|---|
application | Build an Angular application targeting a browser and server environment using esbuild. |
app-shell | Build an Angular App shell. |
browser | Build an Angular application targeting a browser environment using Webpack. |
browser-esbuild | Build an Angular application targeting a browser environment using esbuild. |
dev-server | A development server that provides live reloading. |
extract-i18n | Extract i18n messages from an Angular application. |
karma | Execute unit tests using Karma test runner. |
ng-packagr | Build and package an Angular library in Angular Package Format (APF) format using ng-packagr. |
prerender | Prerender pages of your application. Prerendering is the process where a dynamic page is processed at build time generating static HTML. |
server | Build an Angular application targeting a Node.js environment. |
ssr-dev-server | A development server which offers live reload during development, but uses server-side rendering. |
protractor | Deprecated - Run end-to-end tests using Protractor framework. |
Disclaimer
While the builders when executed via the Angular CLI and their associated options are considered stable, the programmatic APIs are not considered officially supported and are not subject to the breaking change guarantees of SemVer.