@@ -10,8 +10,10 @@ import { join } from "path";
1010import { from , switchMap , tap } from "rxjs" ;
1111import { NgxEnvSchema } from "../ngx-env/ngx-env-schema" ;
1212import { getEnvironment } from "../utils/get-environment" ;
13- import { indexHtml } from "../utils/index-html-build " ;
13+ import { writeRuntimeFile } from "../utils/write-ngx-env-runtime " ;
1414import { getProjectCwd } from "../utils/project" ;
15+ import { replaceHtmlVars } from "../utils/replace-html-vars" ;
16+ import { indexHtmlTransformer } from "../utils/index-html-transform" ;
1517
1618export const executeWithEnv = (
1719 options : ApplicationBuilderOptions & NgxEnvSchema ,
@@ -28,20 +30,30 @@ export const executeWithEnv = (
2830 } ) ;
2931 options . define = full ;
3032 return fromAsyncIterable < BuilderOutput > (
31- buildApplication ( options , context )
33+ buildApplication ( options , context , {
34+ indexHtmlTransformer : async ( html ) => {
35+ return indexHtmlTransformer (
36+ html ,
37+ raw ,
38+ false ,
39+ dotEnvOptions . runtime
40+ ) ;
41+ } ,
42+ } )
3243 ) . pipe (
3344 tap ( ( ) => {
34- const outputDir = join (
35- context . workspaceRoot ,
36- options . outputPath ?. toString ( ) ?? `dist/${ context . target . project } `
37- ) ;
38- indexHtml (
39- join ( outputDir , "browser" ) ,
40- options . ssr ? join ( outputDir , "server" ) : null ,
41- Array . isArray ( options . localize ) ? options . localize : [ ] ,
42- raw ,
43- dotEnvOptions . runtime
44- ) ;
45+ if ( dotEnvOptions . runtime ) {
46+ const outputDir = join (
47+ context . workspaceRoot ,
48+ options . outputPath ?. toString ( ) ?? `dist/${ context . target . project } `
49+ ) ;
50+ writeRuntimeFile (
51+ join ( outputDir , "browser" ) ,
52+ options . ssr ? join ( outputDir , "server" ) : null ,
53+ Array . isArray ( options . localize ) ? options . localize : [ ] ,
54+ raw
55+ ) ;
56+ }
4557 } )
4658 ) ;
4759 } )
0 commit comments