@@ -10,50 +10,51 @@ export default class EncoreProvider {
1010 throw new Error ( 'You need to install the @adonisjs/view package to use this package.' )
1111 }
1212
13- this . $container . with ( [ 'Adonis/Core/Application' , 'Adonis/Core/View' ] , async ( Application : ApplicationContract , View ) => {
14- try {
15- const entrypointsFilePath = Application . publicPath ( '/build/entrypoints.json' )
16- const file = await readFile ( entrypointsFilePath )
17- const { entrypoints, integrity } = JSON . parse ( file . toString ( ) )
13+ this . $container . with ( [ 'Adonis/Core/Application' , 'Adonis/Core/View' ] ,
14+ async ( Application : ApplicationContract , View ) => {
15+ try {
16+ const entrypointsFilePath = Application . publicPath ( '/build/entrypoints.json' )
17+ const entrypointsFile = await readFile ( entrypointsFilePath )
18+ const { entrypoints, integrity } = JSON . parse ( entrypointsFile . toString ( ) )
1819
19- View . global ( 'encoreLink' , ( entry : string ) => {
20- const files = entrypoints [ entry ] [ 'css' ]
20+ View . global ( 'encoreLink' , ( entry : string ) => {
21+ const files = entrypoints [ entry ] [ 'css' ]
2122
22- return files . map ( ( file : string ) => {
23- let html = `<link rel="stylesheet" href="${ file } "`
23+ return files . map ( ( file : string ) => {
24+ let html = `<link rel="stylesheet" href="${ file } "`
2425
25- if ( integrity && integrity [ file ] ) {
26- html += ` integrity="${ integrity [ file ] } "`
27- }
26+ if ( integrity && integrity [ file ] ) {
27+ html += ` integrity="${ integrity [ file ] } "`
28+ }
2829
29- html += '>'
30+ html += '>'
3031
31- return html
32- } ) . join ( '' )
33- } )
32+ return html
33+ } ) . join ( '' )
34+ } )
3435
35- View . global ( 'encoreScript' , ( entry : string , defer = true ) => {
36- const files = entrypoints [ entry ] [ 'js' ]
36+ View . global ( 'encoreScript' , ( entry : string , defer = true ) => {
37+ const files = entrypoints [ entry ] [ 'js' ]
3738
38- return files . map ( ( file : string ) => {
39- let html = `<script src="${ file } "`
39+ return files . map ( ( file : string ) => {
40+ let html = `<script src="${ file } "`
4041
41- if ( integrity && integrity [ file ] ) {
42- html += ` integrity="${ integrity [ file ] } "`
43- }
42+ if ( integrity && integrity [ file ] ) {
43+ html += ` integrity="${ integrity [ file ] } "`
44+ }
4445
45- if ( defer ) {
46- html += ' defer'
47- }
46+ if ( defer ) {
47+ html += ' defer'
48+ }
4849
49- html += '></script>'
50+ html += '></script>'
5051
51- return html
52- } ) . join ( '' )
53- } )
54- } catch ( e ) {
55- //
56- }
57- } )
52+ return html
53+ } ) . join ( '' )
54+ } )
55+ } catch ( e ) {
56+ //
57+ }
58+ } )
5859 }
5960}
0 commit comments