@@ -10,6 +10,7 @@ import util, { hashShort, reHashJs, reHttp, reModuleExt, reStyleModuleExt } from
10
10
import './vendor/clean-css-builds/v4.2.2.js'
11
11
import { Document } from './vendor/deno-dom/document.ts'
12
12
import less from './vendor/less/less.js'
13
+ import { version } from './version.ts'
13
14
14
15
const { CleanCSS } = window as any
15
16
const cleanCSS = new CleanCSS ( { compatibility : '*' /* Internet Explorer 10+ */ } )
@@ -40,6 +41,7 @@ export default class Project {
40
41
readonly config : Config
41
42
readonly ready : Promise < void >
42
43
44
+ #buildId: string = ''
43
45
#modules: Map < string , Module > = new Map ( )
44
46
#pageModules: Map < string , { moduleId : string , rendered : Map < string , RenderResult > } > = new Map ( )
45
47
#fsWatchListeners: Array < EventEmitter > = [ ]
@@ -77,8 +79,12 @@ export default class Project {
77
79
return path . join ( this . rootDir , this . config . srcDir )
78
80
}
79
81
82
+ get buildId ( ) {
83
+ return this . #buildId
84
+ }
85
+
80
86
get buildDir ( ) {
81
- return path . join ( this . rootDir , '.aleph' , this . mode + '. ' + this . config . buildTarget )
87
+ return path . join ( this . rootDir , '.aleph' , 'build- ' + this . buildId )
82
88
}
83
89
84
90
get apiPaths ( ) {
@@ -375,6 +381,9 @@ export default class Project {
375
381
if ( typeof sourceMap === 'boolean' ) {
376
382
Object . assign ( this . config , { sourceMap } )
377
383
}
384
+
385
+ // Gen build ID after config loaded
386
+ this . #buildId = ( new Sha1 ( ) ) . update ( this . mode + '.' + this . config . buildTarget + '.' + version ) . hex ( ) . slice ( 0 , 18 )
378
387
}
379
388
380
389
private async _init ( ) {
@@ -390,6 +399,7 @@ export default class Project {
390
399
Object . assign ( globalThis , {
391
400
ALEPH_ENV : {
392
401
appDir : this . rootDir ,
402
+ buildId : this . buildId ,
393
403
config : this . config ,
394
404
mode : this . mode ,
395
405
} ,
@@ -845,7 +855,7 @@ export default class Project {
845
855
}
846
856
mod . jsContent = [
847
857
`import { applyCSS } from ${ JSON . stringify ( relativePath (
848
- path . dirname ( path . resolve ( '/' , mod . url ) ) ,
858
+ path . dirname ( mod . url ) ,
849
859
'/-/deno.land/x/aleph/head.js'
850
860
) ) } ;`,
851
861
`applyCSS(${ JSON . stringify ( url ) } , ${ asLink ? JSON . stringify ( path . join ( this . config . baseUrl , '_aleph' , filepath ) ) + ', true' : JSON . stringify ( this . isDev ? `\n${ css } \n` : css ) } );` ,
@@ -1079,8 +1089,8 @@ export default class Project {
1079
1089
const data = await this . getData ( )
1080
1090
const html = renderPage ( data , url , appModule ? App : undefined , Page )
1081
1091
const head = await renderHead ( [
1092
+ appModule ? this . _lookupStyles ( appModule ) : [ ] ,
1082
1093
this . _lookupStyles ( pageModule ) ,
1083
- appModule ? this . _lookupStyles ( appModule ) : [ ]
1084
1094
] . flat ( ) )
1085
1095
ret . code = 200
1086
1096
ret . head = head
0 commit comments