@@ -9,6 +9,7 @@ import { buildSync } from 'esbuild';
99import { cwd , parseArgs } from '../scripts/script-utils.js' ;
1010import inliner from 'web-resource-inliner' ;
1111import { baseEsbuildOptions } from './opts.mjs' ;
12+ import { pages } from './pages.mjs' ;
1213
1314const CWD = cwd ( import . meta. url ) ;
1415const ROOT = join ( CWD , '../' ) ;
@@ -17,65 +18,16 @@ const args = parseArgs(process.argv.slice(2), []);
1718const NODE_ENV = args . env || 'production' ;
1819const DEBUG = Boolean ( args . debug ) ;
1920
20- export const support = {
21- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
22- duckplayer : {
23- integration : [ 'copy' , 'build-js' ] ,
24- windows : [ 'copy' , 'build-js' ] ,
25- apple : [ 'copy' , 'build-js' , 'inline-html' ] ,
26- android : [ 'copy' , 'build-js' ] ,
27- } ,
28- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
29- errorpage : {
30- integration : [ 'copy' ] ,
31- apple : [ 'copy' , 'inline-html' ] ,
32- } ,
33- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
34- onboarding : {
35- integration : [ 'copy' , 'build-js' ] ,
36- windows : [ 'copy' , 'build-js' ] ,
37- apple : [ 'copy' , 'build-js' ] ,
38- } ,
39- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
40- example : {
41- integration : [ 'copy' , 'build-js' ] ,
42- } ,
43- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
44- 'release-notes' : {
45- integration : [ 'copy' , 'build-js' ] ,
46- apple : [ 'copy' , 'build-js' ] ,
47- windows : [ 'copy' , 'build-js' ] ,
48- } ,
49- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
50- 'special-error' : {
51- integration : [ 'copy' , 'build-js' ] ,
52- apple : [ 'copy' , 'build-js' , 'inline-html' ] ,
53- windows : [ 'copy' , 'build-js' , 'inline-html' ] ,
54- } ,
55- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
56- 'new-tab' : {
57- integration : [ 'copy' , 'build-js' ] ,
58- windows : [ 'copy' , 'build-js' ] ,
59- apple : [ 'copy' , 'build-js' ] ,
60- } ,
61- /** @type {Partial<Record<ImportMeta['injectName'], string[]>> } */
62- history : {
63- integration : [ 'copy' , 'build-js' ] ,
64- windows : [ 'copy' , 'build-js' ] ,
65- apple : [ 'copy' , 'build-js' ] ,
66- } ,
67- } ;
68-
6921/** @type {{src: string, dest: string, dist: string, injectName: string}[] } */
7022const copyJobs = [ ] ;
71- /** @type {{outputDir: string, injectName: ImportMeta['injectName'], pageName: string}[] } */
23+ /** @type {{outputDir: string, injectName: ImportMeta['injectName'], pageName: string, entry?: string[] }[] } */
7224const buildJobs = [ ] ;
7325/** @type {{src: string}[] } */
7426const inlineJobs = [ ] ;
7527const errors = [ ] ;
7628const DRY_RUN = false ;
7729
78- for ( const [ pageName , injectNames ] of Object . entries ( support ) ) {
30+ for ( const [ pageName , injectNames ] of Object . entries ( pages ) ) {
7931 const publicDir = join ( CWD , 'pages' , pageName , 'public' ) ;
8032 if ( ! existsSync ( publicDir ) ) {
8133 errors . push ( `${ publicDir } does not exist. Each page must have a 'src' directory` ) ;
@@ -104,6 +56,15 @@ for (const [pageName, injectNames] of Object.entries(support)) {
10456 pageName,
10557 } ) ;
10658 }
59+ if ( job === 'build-css' ) {
60+ const outputDir = join ( pageOutputDirectory , 'dist' ) ;
61+ buildJobs . push ( {
62+ outputDir,
63+ injectName : /** @type {ImportMeta['injectName'] } */ ( injectNameKey ) ,
64+ pageName,
65+ entry : [ 'index.css' ] ,
66+ } ) ;
67+ }
10768 if ( job === 'inline-html' ) {
10869 const htmlSrc = join ( pageOutputDirectory , 'index.html' ) ;
10970 inlineJobs . push ( { src : htmlSrc } ) ;
@@ -142,7 +103,10 @@ for (const buildJob of buildJobs) {
142103 if ( DEBUG ) console . log ( '\t- import.meta.env: ' , NODE_ENV ) ;
143104 if ( DEBUG ) console . log ( '\t- import.meta.injectName: ' , buildJob . injectName ) ;
144105 if ( ! DRY_RUN ) {
145- const opts = baseEsbuildOptions ( buildJob . pageName , buildJob . injectName , NODE_ENV , buildJob . outputDir ) ;
106+ /** @type {import('./opts.mjs').EsbuildOptionsConfig } */
107+ const config = { output : buildJob . outputDir } ;
108+ if ( buildJob . entry ) config . entry = buildJob . entry ;
109+ const opts = baseEsbuildOptions ( buildJob . pageName , buildJob . injectName , NODE_ENV , config ) ;
146110 buildSync ( opts ) ;
147111 }
148112}
0 commit comments