@@ -10,6 +10,7 @@ import util, { hashShort, reHashJs, reHttp, reModuleExt, reStyleModuleExt } from
1010import './vendor/clean-css-builds/v4.2.2.js'
1111import { Document } from './vendor/deno-dom/document.ts'
1212import less from './vendor/less/less.js'
13+ import { version } from './version.ts'
1314
1415const { CleanCSS } = window as any
1516const cleanCSS = new CleanCSS ( { compatibility : '*' /* Internet Explorer 10+ */ } )
@@ -40,6 +41,7 @@ export default class Project {
4041 readonly config : Config
4142 readonly ready : Promise < void >
4243
44+ #buildId: string = ''
4345 #modules: Map < string , Module > = new Map ( )
4446 #pageModules: Map < string , { moduleId : string , rendered : Map < string , RenderResult > } > = new Map ( )
4547 #fsWatchListeners: Array < EventEmitter > = [ ]
@@ -77,8 +79,12 @@ export default class Project {
7779 return path . join ( this . rootDir , this . config . srcDir )
7880 }
7981
82+ get buildId ( ) {
83+ return this . #buildId
84+ }
85+
8086 get buildDir ( ) {
81- return path . join ( this . rootDir , '.aleph' , this . mode + '. ' + this . config . buildTarget )
87+ return path . join ( this . rootDir , '.aleph' , 'build- ' + this . buildId )
8288 }
8389
8490 get apiPaths ( ) {
@@ -375,6 +381,9 @@ export default class Project {
375381 if ( typeof sourceMap === 'boolean' ) {
376382 Object . assign ( this . config , { sourceMap } )
377383 }
384+
385+ // Gen build ID after config loaded
386+ this . #buildId = ( new Sha1 ( ) ) . update ( this . mode + '.' + this . config . buildTarget + '.' + version ) . hex ( ) . slice ( 0 , 18 )
378387 }
379388
380389 private async _init ( ) {
@@ -390,6 +399,7 @@ export default class Project {
390399 Object . assign ( globalThis , {
391400 ALEPH_ENV : {
392401 appDir : this . rootDir ,
402+ buildId : this . buildId ,
393403 config : this . config ,
394404 mode : this . mode ,
395405 } ,
@@ -845,7 +855,7 @@ export default class Project {
845855 }
846856 mod . jsContent = [
847857 `import { applyCSS } from ${ JSON . stringify ( relativePath (
848- path . dirname ( path . resolve ( '/' , mod . url ) ) ,
858+ path . dirname ( mod . url ) ,
849859 '/-/deno.land/x/aleph/head.js'
850860 ) ) } ;`,
851861 `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 {
10791089 const data = await this . getData ( )
10801090 const html = renderPage ( data , url , appModule ? App : undefined , Page )
10811091 const head = await renderHead ( [
1092+ appModule ? this . _lookupStyles ( appModule ) : [ ] ,
10821093 this . _lookupStyles ( pageModule ) ,
1083- appModule ? this . _lookupStyles ( appModule ) : [ ]
10841094 ] . flat ( ) )
10851095 ret . code = 200
10861096 ret . head = head
0 commit comments