File tree Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Expand file tree Collapse file tree 5 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ bl2bl_bin.bl2bl(
4545 srcs = ["src/browserslist/package.json" ],
4646 outs = ["src/browserslist/.browserslistrc" ],
4747 chdir = "%s/src/browserslist" % package_name (),
48+ visibility = ["//packages/schematics/angular:__pkg__" ],
4849)
4950
5051RUNTIME_ASSETS = glob (
Original file line number Diff line number Diff line change @@ -42,11 +42,20 @@ copy_to_bin(
4242 srcs = glob (["**/schema.json" ]),
4343)
4444
45+ # Copy the generated browserslist file into this package.
46+ genrule (
47+ name = "angular_browserslist" ,
48+ srcs = ["//packages/angular/build:angular_browserslist" ],
49+ outs = ["config/.browserslistrc" ],
50+ cmd = "cp $< $@" ,
51+ )
52+
4553RUNTIME_ASSETS = [
4654 "collection.json" ,
4755 "migrations/migration-collection.json" ,
4856 "package.json" ,
4957 "utility/latest-versions/package.json" ,
58+ ":angular_browserslist" ,
5059] + glob (
5160 include = [
5261 "*/schema.json" ,
Original file line number Diff line number Diff line change 88# You can see what browsers were selected by your queries by running:
99# npx browserslist
1010
11- last 2 Chrome versions
12- last 1 Firefox version
13- last 2 Edge major versions
14- last 2 Safari major versions
15- last 2 iOS major versions
16- last 2 Android major versions
17- Firefox ESR
11+ <%= config %>
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717 strings ,
1818 url ,
1919} from '@angular-devkit/schematics' ;
20+ import { promises as fs } from 'node:fs' ;
2021import { posix as path } from 'node:path' ;
2122import { relativePathToWorkspaceRoot } from '../utility/paths' ;
2223import { getWorkspace as readWorkspace , updateWorkspace } from '../utility/workspace' ;
@@ -42,10 +43,13 @@ function addBrowserslistConfig(options: ConfigOptions): Rule {
4243 throw new SchematicsException ( `Project name "${ options . project } " doesn't not exist.` ) ;
4344 }
4445
46+ // Read Angular's default vendored `.browserslistrc` file.
47+ const config = await fs . readFile ( path . join ( __dirname , './.browserslistrc' ) , 'utf8' ) ;
48+
4549 return mergeWith (
4650 apply ( url ( './files' ) , [
4751 filter ( ( p ) => p . endsWith ( '.browserslistrc.template' ) ) ,
48- applyTemplates ( { } ) ,
52+ applyTemplates ( { config } ) ,
4953 move ( project . root ) ,
5054 ] ) ,
5155 ) ;
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ describe('Config Schematic', () => {
9494 describe ( `when 'type' is 'browserslist'` , ( ) => {
9595 it ( 'should create a .browserslistrc file' , async ( ) => {
9696 const tree = await runConfigSchematic ( ConfigType . Browserslist ) ;
97- expect ( tree . exists ( 'projects/foo/.browserslistrc' ) ) . toBeTrue ( ) ;
97+ expect ( tree . readContent ( 'projects/foo/.browserslistrc' ) ) . toContain ( 'Chrome >=' ) ;
9898 } ) ;
9999 } ) ;
100100} ) ;
You can’t perform that action at this time.
0 commit comments