* Custom plugin to apply terser during the bundle generation. Vite doesn't minify library ES * modules.
()
| 9 | * modules. |
| 10 | */ |
| 11 | function 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…