|
| 1 | +import { globalExternals } from "@fal-works/esbuild-plugin-global-externals"; |
| 2 | +// import GlobalsPlugin from "esbuild-plugin-globals"; |
1 | 3 | import { defineConfig } from 'tsup';
|
| 4 | +// import externalGlobalPlugin from 'esbuild-plugin-external-global'; |
2 | 5 |
|
3 | 6 | export default defineConfig(() => {
|
4 | 7 | return {
|
| 8 | + bundle: true, |
5 | 9 | dts: false, // d.ts files are use useless at runtime
|
6 | 10 | entry: {
|
7 |
| - 'js/bundle': 'src/main/resources/assets/js/main.ts', |
| 11 | + 'js/app-users-bundle': 'src/main/resources/assets/js/main.ts', |
8 | 12 | 'js/crypto-worker': 'src/main/resources/assets/js/worker/RSAKeysWorker.ts',
|
9 | 13 | },
|
| 14 | + // esbuildOptions(options, context) { |
| 15 | + // options.external = [ |
| 16 | + // 'jquery' |
| 17 | + // ] |
| 18 | + // }, |
| 19 | + esbuildPlugins: [ |
| 20 | + // GlobalsPlugin({ |
| 21 | + // // 'jquery': 'jQuery', |
| 22 | + // 'jquery': '$' |
| 23 | + // }), |
| 24 | + globalExternals({ |
| 25 | + 'jquery': '$' |
| 26 | + // 'jquery': 'jQuery' |
| 27 | + }) |
| 28 | + // externalGlobalPlugin({ |
| 29 | + // // 'react': 'window.React', |
| 30 | + // // 'react-dom': 'window.ReactDOM', |
| 31 | + // 'jQuery': '$' // It seems jquery is available as $ in the global scope |
| 32 | + // }) |
| 33 | + ], |
| 34 | + // external: [ |
| 35 | + // // This will leave require('jquery') as is in the bundle |
| 36 | + // // causes: Uncaught ReferenceError: require is not defined |
| 37 | + // 'jquery' |
| 38 | + // ], |
10 | 39 | format: [
|
11 | 40 | 'cjs'
|
12 | 41 | ],
|
13 |
| - minify: process.env.NODE_ENV === 'development' ? false : true, |
| 42 | + minify: process.env.NODE_ENV !== 'development', |
| 43 | + noExternal: [ // Same as dependencies in package.json |
| 44 | + /@enonic\/lib-admin-ui/, |
| 45 | + 'hasher', |
| 46 | + 'jquery', // This will bundle jQuery into the bundle |
| 47 | + 'nanoid', |
| 48 | + 'owasp-password-strength-test', |
| 49 | + 'q' |
| 50 | + ], |
14 | 51 | outDir: 'build/resources/main/assets',
|
15 | 52 | platform: 'browser',
|
16 |
| - silent: ['QUIET', 'WARN'].includes(process.env.LOG_LEVEL_FROM_GRADLE||''), |
| 53 | + silent: ['QUIET', 'WARN'].includes(process.env.LOG_LEVEL_FROM_GRADLE||''), |
17 | 54 | // splitting: false,
|
18 |
| - sourcemap: process.env.NODE_ENV === 'development' ? true : false, |
| 55 | + sourcemap: process.env.NODE_ENV === 'development', |
19 | 56 | tsconfig: 'src/main/resources/assets/tsconfig.json',
|
20 | 57 | };
|
21 | 58 | });
|
0 commit comments