tarsk 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/minify.js +0 -53
package/package.json
CHANGED
package/scripts/minify.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { readdir, readFile, writeFile } from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { minify } from 'terser';
|
|
4
|
-
|
|
5
|
-
const distDir = path.join(process.cwd(), 'dist');
|
|
6
|
-
|
|
7
|
-
async function minifyFile(filePath) {
|
|
8
|
-
try {
|
|
9
|
-
// Read the file
|
|
10
|
-
const code = await readFile(filePath, 'utf8');
|
|
11
|
-
|
|
12
|
-
// Minify the code
|
|
13
|
-
const minified = await minify(code, {
|
|
14
|
-
compress: {
|
|
15
|
-
dead_code: true,
|
|
16
|
-
drop_console: false, // Set to true to remove console.log statements
|
|
17
|
-
drop_debugger: true,
|
|
18
|
-
ecma: 2020,
|
|
19
|
-
},
|
|
20
|
-
mangle: true,
|
|
21
|
-
format: {
|
|
22
|
-
comments: false,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Write the minified code back to the file
|
|
27
|
-
await writeFile(filePath, minified.code);
|
|
28
|
-
|
|
29
|
-
console.log(`✅ Minified: ${filePath}`);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.error(`❌ Error minifying ${filePath}:`, err);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function processDirectory(dir) {
|
|
36
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
37
|
-
|
|
38
|
-
for (const entry of entries) {
|
|
39
|
-
const fullPath = path.join(dir, entry.name);
|
|
40
|
-
|
|
41
|
-
if (entry.isDirectory()) {
|
|
42
|
-
await processDirectory(fullPath);
|
|
43
|
-
} else if (entry.name.endsWith('.js')) {
|
|
44
|
-
await minifyFile(fullPath);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.log('🔄 Starting minification process...');
|
|
50
|
-
|
|
51
|
-
processDirectory(distDir)
|
|
52
|
-
.then(() => console.log('✨ Minification complete!'))
|
|
53
|
-
.catch((err) => console.error('❌ Minification failed:', err));
|