Last active
February 19, 2022 14:05
-
-
Save DimaCrafter/8c47e9557f4d49358ee15fff20ff3961 to your computer and use it in GitHub Desktop.
Svelte/Sapper `:global` prefixer for Less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
install (less, mgr) { | |
mgr.addPostProcessor({ | |
process (input, meta) { | |
return input.replace(/:global (.*?)\s*([{,])/g, ':global($1)$2'); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
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