mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 14:03:42 +00:00
fix: webpack error reporting + unintentional whitespace changes
This commit is contained in:
parent
57c2d72e21
commit
4910838ab1
@ -110,7 +110,7 @@ async function build(options){
|
||||
let fullpath = path.join(__dirname, 'src', css_paths[i]);
|
||||
// minify CSS files if not already minified, then concatenate
|
||||
if(css_paths[i].endsWith('.css') && !css_paths[i].endsWith('.min.css')){
|
||||
const minified_css = new CleanCSS({}).minify(fs.readFileSync(fullpath).toString());
|
||||
const minified_css = new CleanCSS({}).minify(fs.readFileSync(fullpath).toString());
|
||||
css += minified_css.styles;
|
||||
}
|
||||
// otherwise, just concatenate the file
|
||||
@ -129,7 +129,7 @@ async function build(options){
|
||||
for(let i = 0; i < js_paths.length; i++){
|
||||
main_array.push(path.join(__dirname, 'src', js_paths[i]));
|
||||
}
|
||||
await webpack({
|
||||
const webpack_opts = {
|
||||
...(await BaseConfig({
|
||||
...options,
|
||||
env: 'prod',
|
||||
@ -138,12 +138,15 @@ async function build(options){
|
||||
optimization: {
|
||||
minimize: true,
|
||||
},
|
||||
}, (err, stats) => {
|
||||
}
|
||||
console.log('webpack opts', webpack_opts);
|
||||
await webpack(webpack_opts, (err, stats) => {
|
||||
if(err){
|
||||
console.error(err);
|
||||
return;
|
||||
throw err;
|
||||
// console.error(err);
|
||||
// return;
|
||||
}
|
||||
if(options?.verbose)
|
||||
//if(options?.verbose)
|
||||
console.log(stats.toString());
|
||||
// write to ./dist/bundle.min.js
|
||||
// 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){
|
||||
// Copy index.js to dist/gui.js
|
||||
// Prepend `window.gui_env="prod";` to `./dist/gui.js`
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, 'dist', 'gui.js'),
|
||||
path.join(__dirname, 'dist', 'gui.js'),
|
||||
`window.gui_env="prod"; \n\n` + fs.readFileSync(path.join(__dirname, 'src', 'index.js'))
|
||||
);
|
||||
|
||||
const copy_these = [
|
||||
'images',
|
||||
'images',
|
||||
'fonts',
|
||||
'favicons',
|
||||
'browserconfig.xml',
|
||||
'manifest.json',
|
||||
'browserconfig.xml',
|
||||
'manifest.json',
|
||||
'favicon.ico',
|
||||
'security.txt',
|
||||
];
|
||||
@ -192,7 +195,7 @@ async function build(options){
|
||||
* also includes the necessary CSS and JavaScript files, as well as the required meta tags for social
|
||||
* media sharing and search engine optimization. The function is designed to be used in development
|
||||
* environments to generate the HTML content for the GUI.
|
||||
*
|
||||
*
|
||||
* @param {Object} options - The configuration options for the GUI.
|
||||
* @param {string} options.env - The environment in which the GUI is running (e.g., "dev" or "prod").
|
||||
* @param {string} options.api_origin - The origin of the API server.
|
||||
@ -204,7 +207,7 @@ async function build(options){
|
||||
* @param {string} options.origin - The origin of the GUI.
|
||||
* @param {string} options.social_card - The URL of the social media card image.
|
||||
* @returns {string} The HTML content for the GUI based on the specified configuration options.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function generateDevHtml(options){
|
||||
let start_t = Date.now();
|
||||
@ -281,7 +284,7 @@ function generateDevHtml(options){
|
||||
// preload images when applicable
|
||||
h += `<link rel="preload" as="image" href="./images/wallpaper.webp">`;
|
||||
h += `</head>`;
|
||||
|
||||
|
||||
h += `<body>`;
|
||||
|
||||
// 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){
|
||||
h += `<script src="${lib_paths[i]}"></script>`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// load images and icons as base64 for performance
|
||||
if(options.env === 'dev'){
|
||||
h += `<script>`;
|
||||
@ -342,9 +345,9 @@ function generateDevHtml(options){
|
||||
</script>`;
|
||||
|
||||
h += `</body>
|
||||
|
||||
</html>`;
|
||||
|
||||
|
||||
</html>`;
|
||||
|
||||
console.log(`/index.js: ` + (Date.now() - start_t)/1000);
|
||||
return h;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user