Skip to content

Commit

Permalink
update mangled script
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan committed Nov 6, 2024
1 parent 77a9ddb commit 79bd90d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/react-template/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const root = ReactDOM.createRoot(rootElement)

root.render(
<React.StrictMode>
<TrilogyProviderStyled>
<TrilogyProviderStyled theme='mangled'>
<HashRouter>
<Router />
</HashRouter>
Expand Down
14 changes: 7 additions & 7 deletions packages/styles/config/plugins/vite-plugin-mangler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
})
}
},
}
Expand Down

0 comments on commit 79bd90d

Please sign in to comment.