11import randomstring from 'randomstring'
22import { viteExternalsPlugin as ViteExternals } from 'vite-plugin-externals'
3+ import { createHtmlPlugin } from 'vite-plugin-html'
4+ import { viteStaticCopy } from 'vite-plugin-static-copy'
35import type { HtmlTagDescriptor } from 'vite'
46import type { Target } from 'vite-plugin-static-copy'
57
@@ -55,11 +57,6 @@ export const setupLibraryExternal = (
5557 dest : './assets/vueuse' ,
5658 rename : `vueuse.components.iife.${ staticSuffix } .js` ,
5759 } ,
58- {
59- src : './node_modules/@vueuse/router/index.iife.min.js' ,
60- dest : './assets/vueuse' ,
61- rename : `vueuse.router.iife.${ staticSuffix } .js` ,
62- } ,
6360 ]
6461
6562 const injectTags = staticTargets
@@ -68,7 +65,9 @@ export const setupLibraryExternal = (
6865 injectTo : 'head' ,
6966 tag : 'script' ,
7067 attrs : {
71- src : `${ isProduction ? baseUrl : '/' } ${ target . dest } /${ target . rename } ` ,
68+ src : isProduction
69+ ? `${ baseUrl } ${ target . dest } /${ target . rename } `
70+ : target . src ,
7271 type : 'text/javascript' ,
7372 } ,
7473 }
@@ -82,18 +81,18 @@ export const setupLibraryExternal = (
8281
8382 '@vueuse/core' : 'VueUse' ,
8483 '@vueuse/components' : 'VueUse' ,
85- '@vueuse/router' : 'VueUse' ,
84+
8685 'vue-demi' : 'VueDemi' ,
8786 } ) ,
88- // ViteStaticCopy({
89- // targets: staticTargets,
90- // }) ,
91- // VitePluginHtml({
92- // minify: false,
93- // inject: {
94- // tags: injectTags,
95-
96- // },
97- // }),
87+ isProduction &&
88+ viteStaticCopy ( {
89+ targets : staticTargets ,
90+ } ) ,
91+ createHtmlPlugin ( {
92+ minify : false ,
93+ inject : {
94+ tags : injectTags ,
95+ } ,
96+ } ) ,
9897 ]
9998}
0 commit comments