@@ -4,11 +4,24 @@ const EmberApp = require('ember-cli/lib/broccoli/ember-app');
44const sortBy = require ( 'lodash.sortby' ) ;
55
66module . exports = function ( defaults ) {
7+ let environment = EmberApp . env ( ) ;
8+ let isProduction = environment === 'production' ;
9+
710 const app = new EmberApp ( defaults , {
811 // Add options here
912 'ember-cli-babel' : {
1013 enableTypeScriptTransform : true ,
1114 } ,
15+ prember : {
16+ enabled : isProduction || process . env . PREMBER === 'true' ,
17+ urls : async function ( ) {
18+ let data = await urlsForPrerender ( ) ;
19+
20+ console . error ( data ) ;
21+
22+ return data ;
23+ } ,
24+ } ,
1225 } ) ;
1326
1427 // Use `app.import` to add additional libraries to the generated
@@ -114,19 +127,17 @@ const createManifest = createUnplugin((options) => {
114127 name : 'create-manifest' ,
115128 async buildStart ( ) {
116129 const path = await import ( 'node:path' ) ;
117- const { globbySync } = await import ( 'globby' ) ;
118130
119- let paths = globbySync ( include , {
120- cwd : path . join ( process . cwd ( ) , src ) ,
121- expandDirectories : true ,
131+ let reshaped = await buildManifest ( {
132+ src,
133+ include,
134+ exclude,
122135 } ) ;
123136
124- paths = paths . filter ( ( path ) => ! exclude . some ( ( pattern ) => path . match ( pattern ) ) ) ;
125-
126137 await this . emitFile ( {
127138 type : 'asset' ,
128139 fileName : path . join ( dest , name ) ,
129- source : JSON . stringify ( reshape ( paths ) ) ,
140+ source : JSON . stringify ( reshaped ) ,
130141 } ) ;
131142 } ,
132143 watchChange ( id ) {
@@ -135,6 +146,32 @@ const createManifest = createUnplugin((options) => {
135146 } ;
136147} ) ;
137148
149+ async function urlsForPrerender ( ) {
150+ let manifest = await buildManifest ( {
151+ src : 'public/docs' ,
152+ include : '**/*' ,
153+ exclude : [ ] ,
154+ } ) ;
155+
156+ return manifest ;
157+ }
158+
159+ async function buildManifest ( options ) {
160+ const { src, include, exclude } = options ;
161+
162+ const path = await import ( 'node:path' ) ;
163+ const { globbySync } = await import ( 'globby' ) ;
164+
165+ let paths = globbySync ( include , {
166+ cwd : path . join ( process . cwd ( ) , src ) ,
167+ expandDirectories : true ,
168+ } ) ;
169+
170+ paths = paths . filter ( ( path ) => ! exclude . some ( ( pattern ) => path . match ( pattern ) ) ) ;
171+
172+ return reshape ( paths ) ;
173+ }
174+
138175/**
139176 * @param {string[] } paths
140177 */
0 commit comments