@@ -110,7 +110,7 @@ async function build(options){
110
110
let fullpath = path . join ( __dirname , 'src' , css_paths [ i ] ) ;
111
111
// minify CSS files if not already minified, then concatenate
112
112
if ( css_paths [ i ] . endsWith ( '.css' ) && ! css_paths [ i ] . endsWith ( '.min.css' ) ) {
113
- const minified_css = new CleanCSS ( { } ) . minify ( fs . readFileSync ( fullpath ) . toString ( ) ) ;
113
+ const minified_css = new CleanCSS ( { } ) . minify ( fs . readFileSync ( fullpath ) . toString ( ) ) ;
114
114
css += minified_css . styles ;
115
115
}
116
116
// otherwise, just concatenate the file
@@ -129,7 +129,7 @@ async function build(options){
129
129
for ( let i = 0 ; i < js_paths . length ; i ++ ) {
130
130
main_array . push ( path . join ( __dirname , 'src' , js_paths [ i ] ) ) ;
131
131
}
132
- await webpack ( {
132
+ const webpack_opts = {
133
133
...( await BaseConfig ( {
134
134
...options ,
135
135
env : 'prod' ,
@@ -138,12 +138,15 @@ async function build(options){
138
138
optimization : {
139
139
minimize : true ,
140
140
} ,
141
- } , ( err , stats ) => {
141
+ }
142
+ console . log ( 'webpack opts' , webpack_opts ) ;
143
+ await webpack ( webpack_opts , ( err , stats ) => {
142
144
if ( err ) {
143
- console . error ( err ) ;
144
- return ;
145
+ throw err ;
146
+ // console.error(err);
147
+ // return;
145
148
}
146
- if ( options ?. verbose )
149
+ // if(options?.verbose)
147
150
console . log ( stats . toString ( ) ) ;
148
151
// write to ./dist/bundle.min.js
149
152
// fs.writeFileSync(path.join(__dirname, 'dist', 'bundle.min.js'), fs.readFileSync(path.join(__dirname, 'dist', 'main.js')));
@@ -154,16 +157,16 @@ async function build(options){
154
157
// Copy index.js to dist/gui.js
155
158
// Prepend `window.gui_env="prod";` to `./dist/gui.js`
156
159
fs . writeFileSync (
157
- path . join ( __dirname , 'dist' , 'gui.js' ) ,
160
+ path . join ( __dirname , 'dist' , 'gui.js' ) ,
158
161
`window.gui_env="prod"; \n\n` + fs . readFileSync ( path . join ( __dirname , 'src' , 'index.js' ) )
159
162
) ;
160
163
161
164
const copy_these = [
162
- 'images' ,
165
+ 'images' ,
163
166
'fonts' ,
164
167
'favicons' ,
165
- 'browserconfig.xml' ,
166
- 'manifest.json' ,
168
+ 'browserconfig.xml' ,
169
+ 'manifest.json' ,
167
170
'favicon.ico' ,
168
171
'security.txt' ,
169
172
] ;
@@ -192,7 +195,7 @@ async function build(options){
192
195
* also includes the necessary CSS and JavaScript files, as well as the required meta tags for social
193
196
* media sharing and search engine optimization. The function is designed to be used in development
194
197
* environments to generate the HTML content for the GUI.
195
- *
198
+ *
196
199
* @param {Object } options - The configuration options for the GUI.
197
200
* @param {string } options.env - The environment in which the GUI is running (e.g., "dev" or "prod").
198
201
* @param {string } options.api_origin - The origin of the API server.
@@ -204,7 +207,7 @@ async function build(options){
204
207
* @param {string } options.origin - The origin of the GUI.
205
208
* @param {string } options.social_card - The URL of the social media card image.
206
209
* @returns {string } The HTML content for the GUI based on the specified configuration options.
207
- *
210
+ *
208
211
*/
209
212
function generateDevHtml ( options ) {
210
213
let start_t = Date . now ( ) ;
@@ -281,7 +284,7 @@ function generateDevHtml(options){
281
284
// preload images when applicable
282
285
h += `<link rel="preload" as="image" href="./images/wallpaper.webp">` ;
283
286
h += `</head>` ;
284
-
287
+
285
288
h += `<body>` ;
286
289
287
290
// To indicate that the GUI is running to any 3rd-party scripts that may be running on the page
@@ -295,7 +298,7 @@ function generateDevHtml(options){
295
298
h += `<script src="${ lib_paths [ i ] } "></script>` ;
296
299
}
297
300
}
298
-
301
+
299
302
// load images and icons as base64 for performance
300
303
if ( options . env === 'dev' ) {
301
304
h += `<script>` ;
@@ -342,9 +345,9 @@ function generateDevHtml(options){
342
345
</script>` ;
343
346
344
347
h += `</body>
345
-
346
- </html>` ;
347
-
348
+
349
+ </html>` ;
350
+
348
351
console . log ( `/index.js: ` + ( Date . now ( ) - start_t ) / 1000 ) ;
349
352
return h ;
350
353
}
0 commit comments