Skip to content

Commit 9f2a26b

Browse files
Update compress.js
1 parent 61aee5e commit 9f2a26b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/compress.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ function compressFile(filePath) {
3333
let content = fs.readFileSync(filePath, 'utf8');
3434

3535
if (filePath.endsWith('.js')) {
36-
content = content.replace(/(?<!["'`])\/\/.*\n/g, '\n');
36+
content = content.replace(/(?<!["'`])\/\/.*\n/g, '\n')
37+
.replace(/(?<!['"`][\s\S]*)\btrue\b(?!['"`][\s\S]*)/g, '!![]')
38+
.replace(/(?<!['"`][\s\S]*)\bfalse\b(?!['"`][\s\S]*)/g, '![]')
39+
.replace(/(?<!['"`][\s\S]*)\bundefined\b(?!['"`][\s\S]*)/g, '[][[]]');
3740
}
3841

3942
content = content.replace(/(\s*["'`])([^"'\n`]*)(["'`]\s*)/g, (match, p1, p2, p3) => {
@@ -76,7 +79,7 @@ findAndCompressFiles(deployDir);
7679

7780
/*
7881
79-
EXAMPLE just.config.js FILE for compressing your static website:
82+
EXAMPLE just.config.js FILE to minify js, css, html files in your static website:
8083
8184
module.exports = {
8285
type: "compressor"

0 commit comments

Comments
 (0)