MCPcopy Index your code
hub / github.com/QwikDev/qwik / customTerserPlugin

Function customTerserPlugin

scripts/submodule-preloader.ts:11–44  ·  view source on GitHub ↗

* Custom plugin to apply terser during the bundle generation. Vite doesn't minify library ES * modules.

()

Source from the content-addressed store, hash-verified

9 * modules.
10 */
11function customTerserPlugin(): Plugin {
12 return {
13 name: 'custom-terser',
14 async renderChunk(code, chunk) {
15 // Only process JavaScript chunks
16 if (!chunk.fileName.endsWith('.mjs') && !chunk.fileName.endsWith('.js')) {
17 return null;
18 }
19
20 // Keep the result readable for debugging
21 const result = await minify(code, {
22 compress: {
23 defaults: false,
24 module: true,
25 hoist_props: true,
26 unused: true,
27 booleans_as_integers: true,
28 },
29 mangle: {
30 toplevel: false,
31 properties: {
32 // use short attribute names for internal properties
33 regex: '^\\$.+\\$$|^[A-Z][a-zA-Z]+$',
34 },
35 },
36 format: {
37 comments: true,
38 },
39 });
40
41 return result.code || null;
42 },
43 };
44}
45
46/**
47 * Builds the qwikloader javascript files using Vite. These files can be used by other tooling, and

Callers 1

submodulePreloaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…