For anyone coming here, there appear to be some edge cases where a plugin we use to strip out unused style rules gets a bit greedy and can strip out some rules used in your custom svelte components. This likely only applies to styles applied through our utility class names, for example:
<p class="uppercase">lorem ipsum<p>
To get around this issue, you have a few different options:
- Use SCSS mixins instead of class names in the component whose styles are being stripped out.
<p>lorem ipsum</p>
<style lang="scss">
@use '@reuters-graphics/graphics-components/dist/scss/mixins' as mixins;
p {
@include mixins.uppercase;
}
</style>
- You can disable the plugin entirely by commenting out this line in
vite.config.ts at the root of your project. Like this:
plugins: [
sveltekit(),
dsv(),
svelteKitPagesPlugin(),
// purgeCss(),
],
- Disabling the plugin will lead to slightly bloated stylesheets for your project. Alternatively, you can also use the plugin's safelisting config options to safe guard specific style rules individually. Like this:
plugins: [
sveltekit(),
dsv(),
svelteKitPagesPlugin(),
purgeCss({
safelist: {
standard: [ 'uppercase' ], // A specific class name
greedy: [
/^text-/, // Regular expressions can be used here to capture several classes
],
},
}),
],
📌 If you have this issue please add a comment here with a link to your project's repo. We're looking for more examples to help nail down why this sometimes happens...
For anyone coming here, there appear to be some edge cases where a plugin we use to strip out unused style rules gets a bit greedy and can strip out some rules used in your custom svelte components. This likely only applies to styles applied through our utility class names, for example:
To get around this issue, you have a few different options:
vite.config.tsat the root of your project. Like this:📌 If you have this issue please add a comment here with a link to your project's repo. We're looking for more examples to help nail down why this sometimes happens...