11import { defineConfig } from 'tsup'
22import { esbuildPluginFilePathExtensions } from 'esbuild-plugin-file-path-extensions'
33import packageJson from './package.json' assert { type : "json " } ;
4- import { copyFileSync , existsSync , mkdirSync } from 'fs' ;
5- import { dirname , join } from 'path' ;
64
75export default defineConfig ( [
86 modernConfig ( {
@@ -32,21 +30,7 @@ function modernConfig(opts) {
3230 replace : {
3331 '{{VERSION}}' : `"${ packageJson . version } "` ,
3432 } ,
35- esbuildPlugins : [ esbuildPluginFilePathExtensions ( { esmExtension : 'js' } ) ] ,
36- onSuccess : async ( ) => {
37- // Copy regions.json to dist/modern/assets/ (industry standard structure)
38- const sourceFile = 'src/assets/regions.json' ;
39- const targetFile = join ( 'dist/modern/assets' , 'regions.json' ) ;
40-
41- if ( existsSync ( sourceFile ) ) {
42- const targetDir = dirname ( targetFile ) ;
43- if ( ! existsSync ( targetDir ) ) {
44- mkdirSync ( targetDir , { recursive : true } ) ;
45- }
46- copyFileSync ( sourceFile , targetFile ) ;
47- console . log ( '✓ Copied regions.json to dist/modern/assets' ) ;
48- }
49- }
33+ esbuildPlugins : [ esbuildPluginFilePathExtensions ( { esmExtension : 'js' } ) ]
5034 }
5135}
5236
@@ -69,20 +53,6 @@ function legacyConfig(opts) {
6953 esbuildOptions ( options ) {
7054 options . jsxImportSource = 'preact' ;
7155 options . jsx = 'automatic'
72- } ,
73- onSuccess : async ( ) => {
74- // Copy regions.json to dist/legacy/assets/ (industry standard structure)
75- const sourceFile = 'src/assets/regions.json' ;
76- const targetFile = join ( 'dist/legacy/assets' , 'regions.json' ) ;
77-
78- if ( existsSync ( sourceFile ) ) {
79- const targetDir = dirname ( targetFile ) ;
80- if ( ! existsSync ( targetDir ) ) {
81- mkdirSync ( targetDir , { recursive : true } ) ;
82- }
83- copyFileSync ( sourceFile , targetFile ) ;
84- console . log ( '✓ Copied regions.json to dist/legacy/assets' ) ;
85- }
8656 }
8757 }
8858}
0 commit comments