Skip to content

Commit f897f38

Browse files
filipesilvavikerman
authored andcommitted
ci: use app with lazy chunk for size tracking
1 parent 5564ce6 commit f897f38

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

tests/legacy-cli/e2e/tests/basic/build.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectFileToMatch, moveDirectory } from '../../utils/fs';
1+
import { expectFileToMatch } from '../../utils/fs';
22
import { ng } from '../../utils/process';
33

44

@@ -18,10 +18,4 @@ export default async function() {
1818
await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[a-zA-Z0-9]{20}\.js/);
1919
await expectFileToMatch('dist/test-project/index.html', /main-es5\.[a-zA-Z0-9]{20}\.js/);
2020
await ng('build', '--prod', '--no-progress', 'test-project');
21-
22-
// Store the production build for artifact storage on CircleCI
23-
if (process.env['CIRCLECI']) {
24-
await ng('build', '--prod', '--output-hashing=none');
25-
await moveDirectory('dist', '/tmp/dist');
26-
}
2721
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { appendToFile, moveDirectory, prependToFile, replaceInFile, writeFile } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
4+
5+
export default async function () {
6+
// Store the production build for artifact storage on CircleCI
7+
if (process.env['CIRCLECI']) {
8+
9+
// Add initial app routing.
10+
// This is done automatically on a new app with --routing but must be done manually on
11+
// existing apps.
12+
const appRoutingModulePath = 'src/app/app-routing.module.ts';
13+
await writeFile(appRoutingModulePath, `
14+
import { NgModule } from '@angular/core';
15+
import { Routes, RouterModule } from '@angular/router';
16+
17+
const routes: Routes = [];
18+
19+
@NgModule({
20+
imports: [RouterModule.forRoot(routes)],
21+
exports: [RouterModule]
22+
})
23+
export class AppRoutingModule { }
24+
`);
25+
await prependToFile('src/app/app.module.ts',
26+
`import { AppRoutingModule } from './app-routing.module';`);
27+
await replaceInFile('src/app/app.module.ts', `imports: [`, `imports: [ AppRoutingModule,`);
28+
await appendToFile('src/app/app.component.html', '<router-outlet></router-outlet>');
29+
30+
// Add a lazy module.
31+
await ng('generate', 'module', 'lazy', '--route=lazy', '--module=app.module');
32+
33+
// Build without hashing and with named chunks to keep have consistent file names.
34+
await ng('build', '--prod', '--output-hashing=none', '--named-chunks=true');
35+
36+
// Upload to the store_artifacts dir listed in .circleci/config.yml
37+
await moveDirectory('dist', '/tmp/dist');
38+
}
39+
}

0 commit comments

Comments
 (0)