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' ;
46
57export default defineConfig ( [
68 modernConfig ( {
@@ -30,7 +32,21 @@ function modernConfig(opts) {
3032 replace : {
3133 '{{VERSION}}' : `"${ packageJson . version } "` ,
3234 } ,
33- esbuildPlugins : [ esbuildPluginFilePathExtensions ( { esmExtension : 'js' } ) ]
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+ }
3450 }
3551}
3652
@@ -54,5 +70,19 @@ function legacyConfig(opts) {
5470 options . jsxImportSource = 'preact' ;
5571 options . jsx = 'automatic'
5672 } ,
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+ }
86+ }
5787 }
5888}
0 commit comments