-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement experimental builders for
build
(browser) and `serv…
…er` (dev-browser) targets
- Loading branch information
1 parent
967f2fc
commit 5b5c022
Showing
27 changed files
with
1,194 additions
and
938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,10 +60,6 @@ typings/ | |
# next.js build output | ||
.next | ||
|
||
# TypeScript | ||
*/**/*.js | ||
*.d.ts | ||
|
||
# Angular | ||
.angular | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.angular | ||
coverage | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
projects/angular-server-side-configuration/builders/browser/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { BuilderContext, createBuilder } from '@angular-devkit/architect'; | ||
import { | ||
BrowserBuilderOptions, | ||
BrowserBuilderOutput, | ||
executeBrowserBuilder, | ||
ExecutionTransformer, | ||
} from '@angular-devkit/build-angular'; | ||
import { IndexHtmlTransform } from '@angular-devkit/build-angular/src/utils/index-file/index-html-generator'; | ||
import { WebpackLoggingCallback } from '@angular-devkit/build-webpack'; | ||
import { json } from '@angular-devkit/core'; | ||
import webpack from 'webpack'; | ||
import { Observable, of } from 'rxjs'; | ||
import { switchMap } from 'rxjs/operators'; | ||
|
||
import { detectVariablesAndBuildNgsscJson, NgsscBuildSchema } from '../ngsscbuild/index'; | ||
|
||
export type NgsscBrowserBuilderOptions = BrowserBuilderOptions & NgsscBuildSchema; | ||
|
||
/** | ||
* Experimental wrapper of the @angular-devkit/build-angular:browser builder for ngssc. | ||
*/ | ||
export function ngsscBuildWebpackBrowser( | ||
options: NgsscBrowserBuilderOptions, | ||
context: BuilderContext, | ||
transforms: { | ||
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>; | ||
logging?: WebpackLoggingCallback; | ||
indexHtml?: IndexHtmlTransform; | ||
} = {} | ||
): Observable<BrowserBuilderOutput> { | ||
return executeBrowserBuilder(options, context, transforms).pipe( | ||
switchMap(async (result) => { | ||
if (result.success) { | ||
await detectVariablesAndBuildNgsscJson( | ||
options, | ||
options, | ||
context, | ||
result.outputPaths.length > 1 | ||
); | ||
} | ||
return result; | ||
}) | ||
); | ||
} | ||
|
||
export default createBuilder<json.JsonObject & NgsscBrowserBuilderOptions>( | ||
ngsscBuildWebpackBrowser | ||
); |
Oops, something went wrong.