Skip to content

Commit 4910838

Browse files
committed
fix: webpack error reporting + unintentional whitespace changes
1 parent 57c2d72 commit 4910838

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/gui/utils.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async function build(options){
110110
let fullpath = path.join(__dirname, 'src', css_paths[i]);
111111
// minify CSS files if not already minified, then concatenate
112112
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());
114114
css += minified_css.styles;
115115
}
116116
// otherwise, just concatenate the file
@@ -129,7 +129,7 @@ async function build(options){
129129
for(let i = 0; i < js_paths.length; i++){
130130
main_array.push(path.join(__dirname, 'src', js_paths[i]));
131131
}
132-
await webpack({
132+
const webpack_opts = {
133133
...(await BaseConfig({
134134
...options,
135135
env: 'prod',
@@ -138,12 +138,15 @@ async function build(options){
138138
optimization: {
139139
minimize: true,
140140
},
141-
}, (err, stats) => {
141+
}
142+
console.log('webpack opts', webpack_opts);
143+
await webpack(webpack_opts, (err, stats) => {
142144
if(err){
143-
console.error(err);
144-
return;
145+
throw err;
146+
// console.error(err);
147+
// return;
145148
}
146-
if(options?.verbose)
149+
//if(options?.verbose)
147150
console.log(stats.toString());
148151
// write to ./dist/bundle.min.js
149152
// 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){
154157
// Copy index.js to dist/gui.js
155158
// Prepend `window.gui_env="prod";` to `./dist/gui.js`
156159
fs.writeFileSync(
157-
path.join(__dirname, 'dist', 'gui.js'),
160+
path.join(__dirname, 'dist', 'gui.js'),
158161
`window.gui_env="prod"; \n\n` + fs.readFileSync(path.join(__dirname, 'src', 'index.js'))
159162
);
160163

161164
const copy_these = [
162-
'images',
165+
'images',
163166
'fonts',
164167
'favicons',
165-
'browserconfig.xml',
166-
'manifest.json',
168+
'browserconfig.xml',
169+
'manifest.json',
167170
'favicon.ico',
168171
'security.txt',
169172
];
@@ -192,7 +195,7 @@ async function build(options){
192195
* also includes the necessary CSS and JavaScript files, as well as the required meta tags for social
193196
* media sharing and search engine optimization. The function is designed to be used in development
194197
* environments to generate the HTML content for the GUI.
195-
*
198+
*
196199
* @param {Object} options - The configuration options for the GUI.
197200
* @param {string} options.env - The environment in which the GUI is running (e.g., "dev" or "prod").
198201
* @param {string} options.api_origin - The origin of the API server.
@@ -204,7 +207,7 @@ async function build(options){
204207
* @param {string} options.origin - The origin of the GUI.
205208
* @param {string} options.social_card - The URL of the social media card image.
206209
* @returns {string} The HTML content for the GUI based on the specified configuration options.
207-
*
210+
*
208211
*/
209212
function generateDevHtml(options){
210213
let start_t = Date.now();
@@ -281,7 +284,7 @@ function generateDevHtml(options){
281284
// preload images when applicable
282285
h += `<link rel="preload" as="image" href="./images/wallpaper.webp">`;
283286
h += `</head>`;
284-
287+
285288
h += `<body>`;
286289

287290
// 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){
295298
h += `<script src="${lib_paths[i]}"></script>`;
296299
}
297300
}
298-
301+
299302
// load images and icons as base64 for performance
300303
if(options.env === 'dev'){
301304
h += `<script>`;
@@ -342,9 +345,9 @@ function generateDevHtml(options){
342345
</script>`;
343346

344347
h += `</body>
345-
346-
</html>`;
347-
348+
349+
</html>`;
350+
348351
console.log(`/index.js: ` + (Date.now() - start_t)/1000);
349352
return h;
350353
}

0 commit comments

Comments
 (0)