Skip to content

Commit

Permalink
Added toggle for generating source maps in production
Browse files Browse the repository at this point in the history
  • Loading branch information
Naviary2 committed Jul 11, 2024
1 parent 339054e commit 64b3482
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { minify } from "terser";
import { DEV_BUILD } from "./src/server/config/config.js";
import { exit } from "node:process";

/** Whether to generate source maps in production */
const generateSourceMapsInProduction = false;

/**
*
* @param {string} path
Expand Down Expand Up @@ -68,16 +71,16 @@ for (const file of clientFiles) {
const minified = await minify(minifyInput, {
mangle: true, // Disable variable name mangling
compress: true, // Enable compression
sourceMap: {
sourceMap: generateSourceMapsInProduction ? {
includeSources: true,
url: `${getFilenamePath(file)}.map`,
}
} : false
});

filesToWrite.push(
writeFile(`./dist/${file}`, minified.code, 'utf8'),
writeFile(`./dist/${file}.map`, minified.map, 'utf8')
);
filesToWrite.push(writeFile(`./dist/${file}`, minified.code, 'utf8'));
if (generateSourceMapsInProduction) {
filesToWrite.push(writeFile(`./dist/${file}.map`, minified.map, 'utf8') )
}
}

await Promise.all(filesToWrite);

0 comments on commit 64b3482

Please sign in to comment.