790 Commits

Author SHA1 Message Date
Alan Agius
4d2f4ec2c1 fix(@angular-devkit/build-angular): override already existing assets in compilation
With this change we align the copying of assets between `ng build` and `ng serve`. Previously in `ng serve` already copied assets where not overridden.

More info: https://webpack.js.org/plugins/copy-webpack-plugin/#force

Closes #18787
2020-10-15 17:16:59 +02:00
Alan Agius
1d0d90e1b1 refactor(@angular-devkit/build-angular): simplify global_defs usage from @angular/compiler-cli.
This change results in the same options being set. See: 66e6b932d8/packages/compiler-cli/src/tooling.ts (L25-L34)
2020-10-15 16:10:35 +02:00
Alan Agius
e253fffbe6 refactor(@angular-devkit/build-angular): move addition of HMR plugins and loaders to webpack configs 2020-10-14 21:57:47 +03:00
Alan Agius
7253802d74 refactor(@angular-devkit/build-angular): change hmr-accept to TypeScript
For the time being we cannot use the DOM lib because it conflicts with Node, In future when we remove `yarn admin build` we should have this as a seperate compilation unit.
2020-10-14 21:57:47 +03:00
Alan Agius
c345ec369f test(@angular-devkit/build-angular): test HMR using puppeteer 2020-10-14 21:57:47 +03:00
Alan Agius
16f7767983 fix(@angular-devkit/build-angular): remove .js files equivalent of css when using extract css 2020-10-14 21:57:47 +03:00
Alan Agius
221e821cad refactor(@angular-devkit/build-angular): use __filename instead of __dirname + filename 2020-10-14 21:57:47 +03:00
Alan Agius
e30e578d22 build: update mini-css-extract-plugin to version 1.0.0 2020-10-14 21:57:47 +03:00
Alan Agius
3c2da34972 fix(@angular-devkit/build-angular): only show cannot restore inputs/options when old length is > 0 2020-10-14 21:57:47 +03:00
Alan Agius
49841f84c5 fix(@angular-devkit/build-angular): include HMR accept code in main.ts
This fixes as issue where in some cases the changed module is not accepted which cases the dev-server to fallback to live-reload.

This is because the hmr.js and main.ts have different module ids.
2020-10-14 21:57:47 +03:00
Alan Agius
871dd6a434 feat(@angular-devkit/build-angular): enable font inlining optimizations
With this change we inline Google fonts and icons in the index html file when optimization is enabled.

**Before**
```html
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
```
**After**
```html
<style>
  @font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url(https://fonts.gstatic.com/s/materialicons/v55/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
  }

  .material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
  }
</style>
```

To opt-out of this feature set `optimization.fonts: false` or `optimization.fonts.inline: false` in the browser builder options.

Example:
```js
"configurations": {
  "production": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.prod.ts"
      }
    ],
    "optimization": {
      "fonts": false
    },
```

More information about the motivation for this feature can be found: https://github.com/angular/angular-cli/issues/18730

Note: internet access is required during the build for this optimization to work.
2020-10-14 21:57:29 +03:00
Alan Agius
d8f758758c refactor(@angular-devkit/build-angular): add disk cache to font inliner 2020-10-14 21:57:29 +03:00
Alan Agius
2e6ad9e847 build: add @types/cacache 2020-10-14 21:57:29 +03:00
Alan Agius
6ec40d3a4d feat(@angular-devkit/build-angular): add font inliner
This is the base functionality needed to inline Google fonts and Icons in HTML.

The processor does a couple of things:
1. When support for older devices is needed where woff2 is not supported it will inline definitions for both woff1 and woff2
2. Will remove comments and whitespaces when it's `minifyInlinedCSS` is enabled.
3. Cache responses so to resuse the font response during watch mode.

Note: this is still an internal implementation which users cannot leverage just yet.
2020-10-14 21:57:29 +03:00
Charles Lyding
a4d31fd16e refactor(@angular-devkit/build-angular): fully temporarily disable Webpack 5 license extraction 2020-10-14 10:11:02 -04:00
Bjarki
db00a24b3c feat(@angular-devkit/build-angular): support custom headers in dev-server
Make it possible to configure dev-server to send custom HTTP headers on
every client request. These headers can be specified as a key-value map
under the new "headers" property of the dev-server builder in
angular.json. These headers are then passed on to the webpack devserver.

An example use case for this is to enable various security features,
such as CSP and Trusted Types, both in local application development and
in integration tests, by setting appropriate HTTP headers.

This is part of an effort to add support for Trusted Types in Angular.
The ability to enforce Trusted Types during development and integration
tests is essential, as this can help detect Trusted Types violations
that might otherwise break applications when they're pushed to
production where such security features may be enforced.
2020-10-13 12:36:19 -04:00
Charles Lyding
755cb8dc57 test(@angular-devkit/build-angular): disable experimental Rollup size tests
The experimental Webpack Rollup pass no longer produces smaller sizes than the standard production build.
2020-10-12 11:04:14 -04:00
Alan Agius
997d21d522 fix(@angular-devkit/build-angular): use IE11 as oldest browser when downlevelling 2020-10-09 13:13:18 -04:00
Alan Agius
84b63e5893 refactor(@angular-devkit/build-angular): remove RxJs usage from writeIndexHtml 2020-10-09 13:12:28 -04:00
Charles Lyding
97ba359487 refactor(@angular-devkit/build-angular): remove unneeded 10.1 localize checks
Now that 11.0 is the minimum supported version, the 10.1 support checks for the `@angular/localize` package can be removed.
2020-10-07 14:56:52 -04:00
Charles Lyding
0fe20bcc7f refactor(@angular-devkit/build-angular): additional webpack 5 type improvements
Additional support for building with Webpack 5.
2020-10-07 13:42:52 -04:00
Alan Agius
4e860528d7 refactor(@angular-devkit/build-angular): deprecate tslint builder 2020-10-07 11:12:58 -04:00
Alan Agius
290fe4360d refactor(@angular-devkit/build-angular): deprecate hmrWarning and servePathDefaultWarning options
With this change we deprecate servePathDefaultWarning and hmrWarning which no longer has an effect.

Using any unsupported deploy-url or base-href serve path value will result in a hard warning.
2020-10-07 09:54:32 -04:00
Alan Agius
f33d10d343 refactor(@angular-devkit/build-angular): deprecate a number of dev-server options
With this change we deprecate a number of dev-server builder options which proxied to the browser builder. This pattern also wrongly assumes that 3rd party browser builders also support all these options.

Configure the below deprecated options directly in the browser builder target options instead.

- aot
- sourceMap
- deployurl
- baseHref
- vendorChunk
- commonChunk
- optimization
- progress
2020-10-07 09:54:32 -04:00
Alan Agius
9d71ebf90a refactor(@angular-devkit/build-angular): clean up style include paths logic 2020-10-06 11:34:10 -04:00
Alan Agius
7972ec70dc build: update stylus-loader to version 4.1.0 2020-10-06 11:34:10 -04:00
Alan Agius
409247e9c0 refactor(@angular-devkit/build-angular): use parse5-html-rewriting-stream instead of parse5-htmlparser2-tree-adapter
Closes: #17019
2020-10-05 11:31:49 -04:00
Alan Agius
dcad2ee0d3 fix(@angular-devkit/build-angular): don't process stylesheets in extraction builder
When building an application for i18n extraction we are currently redundantly processing components stylesheets. With this change we replace the components stylesheets with an empty string which helps reduce the i18n build time.
2020-09-30 19:34:08 +02:00
Alan Agius
e96fbd3c8a refactor(@angular-devkit/build-angular): change errors and warnings messages
Sometimes the WARNING IN/ERROR IN can lead of ambiguous messages

 - Use `Warning` instead of `WARNING IN`
-  Use `Error` instead of `Error In`
2020-09-30 16:17:05 +02:00
Alan Agius
aab73e242f refactor(@angular-devkit/build-angular): remove deprecated karma builder environment option
BREAKING CHANGE:

Remove deprecated karma builder `environment` option
2020-09-30 13:49:13 +02:00
Dmitriy Shekhovtsov
c78a460658 fix(@angular-devkit/build-angular): fixes optimizeChunkAssets is deprecated in webpack 5 2020-09-29 15:03:53 +02:00
Dmitriy Shekhovtsov
850a0aef13 fix(@angular-devkit/build-angular): fixes deprecation warning for MainTemplate.hooks.assetPath in webpack 5 2020-09-29 13:53:01 +02:00
Dmitriy Shekhovtsov
d74e7e3f7e fix(@angular-devkit/build-angular): fix webpack 5 deprecation warning for chunk.push 2020-09-29 13:52:00 +02:00
Alan Agius
5e293f039a fix(@angular-devkit/build-angular): handle undefined descriptionFileData
Closes #18631
2020-09-29 13:51:23 +02:00
Dmitriy Shekhovtsov
38023fe41c fix(@angular-devkit/build-angular): fixed afterOptimizeChunkAssets is deprecated in webpack 5 2020-09-29 11:35:20 +02:00
Alan Agius
8d0922eb7d fix(@angular-devkit/build-angular): resolve i18n outFile from workspaceRoot 2020-09-28 21:24:10 +02:00
Alan Agius
bda8bc8b70 test(@angular-devkit/build-angular): fix unit test setup to be able to run new Ivy extraction 2020-09-28 21:24:10 +02:00
Alan Agius
e0244d05de feat(@angular-devkit/build-angular): enable Ivy extraction by default for Ivy applications 2020-09-28 21:24:10 +02:00
Dmitriy Shekhovtsov
c8f8640bf5 fix(@angular-devkit/build-angular): fixed Module.issuer is deprecated in webpack 5 for commonjs warn plugin 2020-09-28 20:34:18 +02:00
Alan Agius
1ec4ea6659 refactor(@angular-devkit/build-angular): use architect build error instead of logger.error 2020-09-28 15:58:26 +02:00
Alan Agius
0a406e8dd0 refactor(@angular-devkit/build-angular) remove _loadTslint method 2020-09-28 15:34:56 +02:00
Alan Agius
96bee9c6a5 refactor(@angular-devkit/build-angular): remove redundant tslint version check
Tslint has been added as an optional peer dependency which makes this check unnecessary since the package manager will issue a warning when an incorrect version is installed.
2020-09-28 15:34:56 +02:00
Alan Agius
1c4d358b38 fix(@angular-devkit/build-angular): implement relative method in extractor FS
This will be needed when the changes in angular/angular#39006 is merged.
2020-09-28 13:58:31 +02:00
Dmitriy Shekhovtsov
92f3889f98 fix(@angular-devkit/build-angular): maxModules were deprecated and renamed to modulesSpace 2020-09-28 13:57:38 +02:00
Dmitriy Shekhovtsov
eb8872aeee fix(@angular-devkit/build-angular): webpack5 deprecation of module property in Dependency 2020-09-28 11:23:41 +02:00
Charles Lyding
1873f2d28f fix(@angular-devkit/build-angular): add tslint as an optional peer dependency
tslint is currently used by the tslint builder within this package but is not represented in the dependencies. The can lead to accidental version mismatches as well as package manager hoisting problems due to the package manager not knowing the full dependency set of the package.
2020-09-25 23:10:56 +02:00
Charles Lyding
7fed4cf7f7 style(@angular-devkit/build-angular): remove unneeded no-implicit-dependencies rule disabling 2020-09-25 23:10:56 +02:00
Charles Lyding
5bbac0774f fix(@angular-devkit/build-angular): add karma as an optional peer dependency
karma is currently used by the karma builder within this package but is not represented in the dependencies.  The can lead to accidental version mismatches as well as package manager hoisting problems due to the package manager not knowing the full dependency set of the package.
2020-09-25 23:10:56 +02:00
Charles Lyding
cdb404bd3c fix(@angular-devkit/build-angular): warn if using unsupported IE9/10 browsers
As of Angular v11, IE9 and IE10 are no longer officially supported.  A warning will now be shown during builds if these browsers are requested in the project's browserslist configuration.
2020-09-25 22:46:04 +02:00
Charles Lyding
0c112e5d91 feat(@angular-devkit/build-angular): support package references in styles & scripts options
The browser builder's `styles` and `scripts` options now support using a package name in the path when specifying a style or script.  This removes the need to use a relative path to the node modules directory in these options.  This provides support for Yarn PnP as well as reducing the complexity of the options especially for monorepo setups.  Relatively located files will take precedence over packages if they exist.  This precedence provides backwards compatibility with existing configurations.

Before :
`"styles": ["../node_modules/bootstrap/dist/css/bootstrap.css"]`

After:
`"styles": ["bootstrap/dist/css/bootstrap.css"]`
2020-09-25 20:22:04 +02:00