7
7
*/
8
8
9
9
import { EmittedFiles } from '@angular-devkit/build-webpack' ;
10
- import { normalize , virtualFs } from '@angular-devkit/core' ;
11
10
import { dirname , join } from 'path' ;
12
11
import { ExtraEntryPoint } from '../../browser/schema' ;
12
+ import { mkdir , readFile , writeFile } from '../fs' ;
13
13
import { generateEntryPoints } from '../package-chunk-sort' ;
14
14
import { stripBom } from '../strip-bom' ;
15
15
import { CrossOriginValue , FileInfo , augmentIndexHtml } from './augment-index-html' ;
16
16
17
17
type ExtensionFilter = '.js' | '.css' ;
18
18
19
19
export interface WriteIndexHtmlOptions {
20
- host : virtualFs . Host ;
21
20
outputPath : string ;
22
21
indexPath : string ;
23
22
files ?: EmittedFiles [ ] ;
@@ -36,7 +35,6 @@ export interface WriteIndexHtmlOptions {
36
35
export type IndexHtmlTransform = ( content : string ) => Promise < string > ;
37
36
38
37
export async function writeIndexHtml ( {
39
- host,
40
38
outputPath,
41
39
indexPath,
42
40
files = [ ] ,
@@ -51,12 +49,9 @@ export async function writeIndexHtml({
51
49
crossOrigin,
52
50
lang,
53
51
} : WriteIndexHtmlOptions ) : Promise < void > {
54
- const readFile = async ( filePath : string ) =>
55
- virtualFs . fileBufferToString ( await host . read ( normalize ( filePath ) ) . toPromise ( ) ) ;
56
-
57
52
let content = await augmentIndexHtml ( {
58
53
input : outputPath ,
59
- inputContent : stripBom ( await readFile ( indexPath ) ) ,
54
+ inputContent : stripBom ( await readFile ( indexPath , 'utf-8' ) ) ,
60
55
baseHref,
61
56
deployUrl,
62
57
crossOrigin,
@@ -66,14 +61,15 @@ export async function writeIndexHtml({
66
61
files : filterAndMapBuildFiles ( files , [ '.js' , '.css' ] ) ,
67
62
noModuleFiles : filterAndMapBuildFiles ( noModuleFiles , '.js' ) ,
68
63
moduleFiles : filterAndMapBuildFiles ( moduleFiles , '.js' ) ,
69
- loadOutputFile : filePath => readFile ( join ( dirname ( outputPath ) , filePath ) ) ,
64
+ loadOutputFile : filePath => readFile ( join ( dirname ( outputPath ) , filePath ) , 'utf-8' ) ,
70
65
} ) ;
71
66
72
67
for ( const transform of postTransforms ) {
73
68
content = await transform ( content ) ;
74
69
}
75
70
76
- await host . write ( normalize ( outputPath ) , virtualFs . stringToFileBuffer ( content ) ) . toPromise ( ) ;
71
+ await mkdir ( dirname ( outputPath ) , { recursive : true } ) ;
72
+ await writeFile ( outputPath , content ) ;
77
73
}
78
74
79
75
function filterAndMapBuildFiles (
0 commit comments