1010 *
1111 */
1212
13- import { useEnv } from '@opentiny/tiny-engine-meta-register'
13+ import { useEnv , getMergeMeta } from '@opentiny/tiny-engine-meta-register'
1414import { importMapConfig as importMapJSON } from '@opentiny/tiny-engine-common/js/importMap'
1515
1616const importMap = { }
1717
1818const opentinyVueVersion = '~3.20'
1919
20- function replacePlaceholder ( v ) {
20+ function replacePlaceholder ( v , k ) {
2121 const {
2222 VITE_CDN_TYPE ,
2323 VITE_CDN_DOMAIN ,
@@ -29,6 +29,14 @@ function replacePlaceholder(v) {
2929 const versionDelimiter = VITE_CDN_TYPE === 'npmmirror' && ! isLocalBundle ? '/' : '@'
3030 const fileDelimiter = VITE_CDN_TYPE === 'npmmirror' && ! isLocalBundle ? '/files' : ''
3131 const cdnDomain = isLocalBundle ? BASE_URL + VITE_LOCAL_IMPORT_PATH : VITE_CDN_DOMAIN
32+ const customImportMap = getMergeMeta ( 'engine.config' ) ?. importMap
33+
34+ if ( customImportMap ?. imports ?. [ k ] ) {
35+ return customImportMap . imports [ k ]
36+ . replace ( '${VITE_CDN_DOMAIN}' , cdnDomain )
37+ . replace ( '${versionDelimiter}' , versionDelimiter )
38+ . replace ( '${fileDelimiter}' , fileDelimiter )
39+ }
3240
3341 return v
3442 . replace ( '${VITE_CDN_DOMAIN}' , cdnDomain )
@@ -39,7 +47,7 @@ function replacePlaceholder(v) {
3947
4048export const getImportMap = ( scripts = { } ) => {
4149 importMap . imports = {
42- ...Object . fromEntries ( Object . entries ( importMapJSON . imports ) . map ( ( [ k , v ] ) => [ k , replacePlaceholder ( v ) ] ) ) ,
50+ ...Object . fromEntries ( Object . entries ( importMapJSON . imports ) . map ( ( [ k , v ] ) => [ k , replacePlaceholder ( v , k ) ] ) ) ,
4351 ...scripts
4452 }
4553
0 commit comments