Skip to content

Instantly share code, notes, and snippets.

@DimaCrafter
Last active February 19, 2022 14:05
Show Gist options
  • Save DimaCrafter/8c47e9557f4d49358ee15fff20ff3961 to your computer and use it in GitHub Desktop.
Save DimaCrafter/8c47e9557f4d49358ee15fff20ff3961 to your computer and use it in GitHub Desktop.
Svelte/Sapper `:global` prefixer for Less
export default {
install (less, mgr) {
mgr.addPostProcessor({
process (input, meta) {
return input.replace(/:global (.*?)\s*([{,])/g, ':global($1)$2');
}
});
}
}
// ...
import { less } from 'svelte-preprocess-less'
import globalStyles from './global-styles'
const preprocess = {
style: less({ plugins: [globalStyles] })
};
export default {
client: {
// ...
plugins: [
svelte({
// ...
preprocess
})
]
},
server: {
// ...
plugins: [
svelte({
// ...
preprocess
})
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment