diff --git a/examples/react-template/index.tsx b/examples/react-template/index.tsx index 52d529c1..584d719f 100644 --- a/examples/react-template/index.tsx +++ b/examples/react-template/index.tsx @@ -9,7 +9,7 @@ const root = ReactDOM.createRoot(rootElement) root.render( - + diff --git a/packages/styles/config/plugins/vite-plugin-mangler.tsx b/packages/styles/config/plugins/vite-plugin-mangler.tsx index f33bef79..853032c1 100644 --- a/packages/styles/config/plugins/vite-plugin-mangler.tsx +++ b/packages/styles/config/plugins/vite-plugin-mangler.tsx @@ -5,13 +5,12 @@ export const cssPlugin = () => { name: 'css-transform', transform(src: string, id: string) { if (/mangled\.(scss)$/.test(id)) { - src.replace(/(\.[a-z][_\-0-9a-z]*)(?=[^\{]*{)/gi, (match) => { - return `${match}__${HASH}` - }) + return src + .replace(/(\.[a-z][_\-0-9a-z]*)(?=[^\{]*{)/gi, (match) => { + return `${match}__${HASH}` + }) - return src.replace(/url\(\s*['"]?[^"')]*$/i, (match) => { - return match.split('_')[0] - }) + .replace(/(url\(["']?.*?)(__[\w]+)(.*?["']?\))/g, '$1$3') } }, }