From 79bd90dcda83f454961e33fe2467bdcd01c60df9 Mon Sep 17 00:00:00 2001 From: erwan Date: Wed, 6 Nov 2024 17:38:03 +0100 Subject: [PATCH 1/2] update mangled script --- examples/react-template/index.tsx | 2 +- .../styles/config/plugins/vite-plugin-mangler.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) 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..2483b84a 100644 --- a/packages/styles/config/plugins/vite-plugin-mangler.tsx +++ b/packages/styles/config/plugins/vite-plugin-mangler.tsx @@ -5,13 +5,13 @@ 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(/url\(\s*['"]?[^"')]*$/i, (match) => { - return match.split('_')[0] - }) + return src + .replace(/(\.[a-z][_\-0-9a-z]*)(?=[^\{]*{)/gi, (match) => { + return `${match}__${HASH}` + }) + .replace(/url\(\s*['"]?[^"')]*$/i, (match) => { + return match.split('_')[0] + }) } }, } From 477fcac2aca595cc8d42fc9b0c77f174a85a4f27 Mon Sep 17 00:00:00 2001 From: erwan Date: Wed, 6 Nov 2024 17:50:50 +0100 Subject: [PATCH 2/2] update script hash class in css --- packages/styles/config/plugins/vite-plugin-mangler.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/styles/config/plugins/vite-plugin-mangler.tsx b/packages/styles/config/plugins/vite-plugin-mangler.tsx index 2483b84a..853032c1 100644 --- a/packages/styles/config/plugins/vite-plugin-mangler.tsx +++ b/packages/styles/config/plugins/vite-plugin-mangler.tsx @@ -9,9 +9,8 @@ export const cssPlugin = () => { .replace(/(\.[a-z][_\-0-9a-z]*)(?=[^\{]*{)/gi, (match) => { return `${match}__${HASH}` }) - .replace(/url\(\s*['"]?[^"')]*$/i, (match) => { - return match.split('_')[0] - }) + + .replace(/(url\(["']?.*?)(__[\w]+)(.*?["']?\))/g, '$1$3') } }, }