File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ export const useStore = (initial: Initial) => {
5151 : undefined
5252 const pr =
5353 new URLSearchParams ( location . search ) . get ( 'pr' ) ||
54- saved ?. _o ?. styleSource ?. split ( '-' , 2 ) [ 1 ]
55- const prUrl = `https://preview- ${ pr } -element-plus.surge.sh/bundle /dist`
54+ saved ?. _o ?. styleSource ?. match ( / e l e m e n t - p l u s @ ( [ ^ / ] + ) / ) ?. [ 1 ]
55+ const prUrl = `https://raw.esm.sh/pr/element-plus@ ${ pr } /dist`
5656 const vuePr =
5757 new URLSearchParams ( location . search ) . get ( 'vue' ) || saved ?. _o ?. vuePr
5858 const vuePrUrl = `https://esm.sh/pr`
@@ -89,7 +89,7 @@ export const useStore = (initial: Initial) => {
8989 importMap = mergeImportMap ( importMap , {
9090 imports : {
9191 'element-plus' : `${ prUrl } /index.full.min.mjs` ,
92- 'element-plus/' : 'unsupported' ,
92+ 'element-plus/' : `https://raw.esm.sh/pr/element-plus@ ${ pr } /` ,
9393 } ,
9494 } )
9595
Original file line number Diff line number Diff line change @@ -85,11 +85,12 @@ export default defineConfig({
8585function patchVueWorker ( code : string ) {
8686 return `${ code }
8787 const pr = new URL(location.href).searchParams.get('pr')
88- if(pr) {
88+ if (pr) {
8989 const _fetch = self.fetch
9090 self.fetch = (...args) => {
91- const shouldReplace = args[0].startsWith("https://cdn.jsdelivr.net/npm/element-plus/es/")
92- if(shouldReplace) { args[0] = args[0].replace("https://cdn.jsdelivr.net/npm/element-plus", \`https://preview-\${pr}-element-plus.surge.sh/bundle\`) }
91+ if (typeof args[0] === 'string' && /https:\\/\\/cdn\\.jsdelivr\\.net\\/npm\\/element-plus(@[^/]+)?\\//.test(args[0])) {
92+ args[0] = args[0].replace(/https:\\/\\/cdn\\.jsdelivr\\.net\\/npm\\/element-plus(@[^/]+)?/, \`https://raw.esm.sh/pr/element-plus@\${pr}\`)
93+ }
9394 return _fetch(...args)
9495 }
9596 }`
You can’t perform that action at this time.
0 commit comments