@@ -11,82 +11,92 @@ import {
1111
1212
1313export default function buildStaticConfig ( ) : Options {
14- const DIR_DST_STATIC = `${ DIR_DST } /static` ;
15- // const GLOB_EXTENSIONS_STATIC = '{tsx,ts,jsx,js}';
16- // const FILES_STATIC = globSync(`${DIR_SRC_STATIC}/**/*.${GLOB_EXTENSIONS_STATIC}`);
14+ const DIR_DST_STATIC = `${ DIR_DST } /static` ;
15+ // const GLOB_EXTENSIONS_STATIC = '{tsx,ts,jsx,js}';
16+ // const FILES_STATIC = globSync(`${DIR_SRC_STATIC}/**/*.${GLOB_EXTENSIONS_STATIC}`);
1717
18- // const entry = {};
19- // for (let i = 0; i < FILES_STATIC.length; i++) {
20- // const element = FILES_STATIC[i];
21- // entry[element
22- // .replace(`${DIR_SRC_STATIC}/`, '') // Remove path
23- // .replace(/\.[^.]+$/, '') // Remove extension
24- // ] = element;
25- // }
26- return {
27- bundle : true ,
28- dts : false ,
29- // entry,
30- entry : {
31- 'app-users-bundle' : 'src/main/resources/static/main.ts' ,
32- 'crypto-worker' : 'src/main/resources/static/worker/RSAKeysWorker.ts' ,
33- } ,
34- // esbuildOptions(options, context) {
35- // // options.banner = {
36- // // js: `const jQuery = window.$;` // jQuery UI Tabbable requires this
37- // // };
38- // // options.external = [
39- // // 'jquery'
40- // // ]
41- // },
42- esbuildPlugins : [
43- CopyWithHashPlugin ( {
44- context : 'node_modules' ,
45- manifest : `node_modules-manifest.json` ,
46- patterns : [
47- 'jquery/dist/*.*' ,
48- 'jquery-ui/dist/*.*' ,
49- ]
50- } ) ,
51- TsupPluginManifest ( {
52- generate : ( entries ) => { // Executed once per format
53- const newEntries = { } ;
54- Object . entries ( entries ) . forEach ( ( [ k , v ] ) => {
55- console . log ( k , v ) ;
56- const ext = v . split ( '.' ) . pop ( ) as string ;
57- const parts = k . replace ( `${ DIR_SRC_STATIC } /` , '' ) . split ( '.' ) ;
58- parts . pop ( ) ;
59- parts . push ( ext ) ;
60- newEntries [ parts . join ( '.' ) ] = v . replace ( `${ DIR_DST_STATIC } /` , '' ) ;
61- } ) ;
62- return newEntries ;
63- }
64- } ) ,
65- ] ,
66- format : [
67- 'cjs'
68- ] ,
18+ // const entry = {};
19+ // for (let i = 0; i < FILES_STATIC.length; i++) {
20+ // const element = FILES_STATIC[i];
21+ // entry[element
22+ // .replace(`${DIR_SRC_STATIC}/`, '') // Remove path
23+ // .replace(/\.[^.]+$/, '') // Remove extension
24+ // ] = element;
25+ // }
26+ return {
27+ bundle : true ,
28+ dts : false ,
29+ // entry,
30+ entry : {
31+ 'app-users-bundle' : 'src/main/resources/static/main.ts' ,
32+ 'crypto-worker' : 'src/main/resources/static/worker/RSAKeysWorker.ts' ,
33+ } ,
34+ // esbuildOptions(options, context) {
35+ // // options.banner = {
36+ // // js: `const jQuery = window.$;` // jQuery UI Tabbable requires this
37+ // // };
38+ // // options.external = [
39+ // // 'jquery'
40+ // // ]
41+ // // options.sourcemap = 'external'; // Shows the line in the transpiled code, not the source
42+ // // options.sourcemap = 'both'; // // Shows the line in the transpiled code, not the source
43+ // },
44+ esbuildPlugins : [
45+ CopyWithHashPlugin ( {
46+ context : 'node_modules' ,
47+ manifest : `node_modules-manifest.json` ,
48+ patterns : [
49+ 'jquery/dist/*.*' ,
50+ 'jquery-ui/dist/*.*' ,
51+ ]
52+ } ) ,
53+ TsupPluginManifest ( {
54+ generate : ( entries ) => { // Executed once per format
55+ const newEntries = { } ;
56+ Object . entries ( entries ) . forEach ( ( [ k , v ] ) => {
57+ console . log ( k , v ) ;
58+ const ext = v . split ( '.' ) . pop ( ) as string ;
59+ const parts = k . replace ( `${ DIR_SRC_STATIC } /` , '' ) . split ( '.' ) ;
60+ parts . pop ( ) ;
61+ parts . push ( ext ) ;
62+ newEntries [ parts . join ( '.' ) ] = v . replace ( `${ DIR_DST_STATIC } /` , '' ) ;
63+ } ) ;
64+ return newEntries ;
65+ }
66+ } ) ,
67+ ] ,
68+ format : [
69+ 'cjs'
70+ ] ,
6971
70- minify : false ,
71- // minify: process.env.NODE_ENV !== 'development',
72+ minify : false ,
73+ // minify: process.env.NODE_ENV !== 'development',
74+ // minify: true, // Causes app-users-bundle-L6FTUX7O.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'insertChild')
7275
73- noExternal : [ // Same as dependencies in package.json
74- / @ e n o n i c \/ l i b - a d m i n - u i .* / ,
75- 'hasher' ,
76- // 'jquery', // This will bundle jQuery into the bundle
77- 'nanoid' ,
78- 'owasp-password-strength-test' ,
79- 'q'
80- ] ,
81- outDir : 'build/resources/main/static' ,
82- platform : 'browser' ,
83- silent : [ 'QUIET' , 'WARN' ] . includes ( process . env . LOG_LEVEL_FROM_GRADLE || '' ) ,
84- splitting : false ,
76+ noExternal : [ // Same as dependencies in package.json
77+ / @ e n o n i c \/ l i b - a d m i n - u i .* / ,
78+ 'hasher' ,
79+ // 'jquery', // This will bundle jQuery into the bundle
80+ 'nanoid' ,
81+ 'owasp-password-strength-test' ,
82+ 'q'
83+ ] ,
84+ outDir : 'build/resources/main/static' ,
85+ platform : 'browser' ,
86+ silent : [ 'QUIET' , 'WARN' ] . includes ( process . env . LOG_LEVEL_FROM_GRADLE || '' ) ,
87+ splitting : false ,
8588
86- // sourcemap: false,
87- sourcemap : process . env . NODE_ENV === 'development' ,
88- // sourcemap: true,
89+ // Let tsconfig handle sourcemap?
90+ // sourcemap: false,
91+ // sourcemap: process.env.NODE_ENV === 'development'
92+ // ? 'inline' // Shows the line in the transpiled code, not the source
93+ // ? true // Shows the source typescript, but currently the wrong line number :(
94+ // : false,
95+ sourcemap : true ,
8996
90- tsconfig : 'src/main/resources/static/tsconfig.json' ,
91- } ;
97+ // TODO: Is this the line that fixed wrong line numbers?
98+ target : 'es2020' ,
99+
100+ tsconfig : 'src/main/resources/static/tsconfig.json' ,
101+ } ;
92102}
0 commit comments