Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(vite): update regex to handle new vite output format
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Apr 1, 2022
1 parent 9a2fc45 commit ccd751c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vite/src/plugins/dynamic-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl
s.replace(/from *['"]\/__NUXT_BASE__(\/[^'"]*)['"]/g, 'from "$1"')

// Dynamically compute string URLs featuring baseURL
for (const delimiter of ['`', '"', "'"]) {
const delimiterRE = new RegExp(`(?<!const base = )${delimiter}([^${delimiter}]*)\\/__NUXT_BASE__\\/([^${delimiter}]*)${delimiter}`, 'g')
for (const delimiter of ['`', "'", '"']) {
const delimiterRE = new RegExp(`(?<!(const base = |from *))${delimiter}([^${delimiter}]*)\\/__NUXT_BASE__\\/([^${delimiter}]*)${delimiter}`, 'g')
/* eslint-disable-next-line no-template-curly-in-string */
s.replace(delimiterRE, '`$1${__publicAssetsURL()}$2`')
s.replace(delimiterRE, r => '`' + r.replace(/\/__NUXT_BASE__\//g, '${__publicAssetsURL()}').slice(1, -1) + '`')
}

if (s.hasChanged()) {
Expand Down

0 comments on commit ccd751c

Please sign in to comment.