- allows us to easily differentiate the exposed components of the npm package vs the dev-only ones - allows the postcss config to purgecss correctly for production build, we do not include the classes seen in the dev components
33 lines
952 B
JavaScript
33 lines
952 B
JavaScript
import purgecss from "@fullhuman/postcss-purgecss"
|
|
import prefixSelector from "postcss-prefix-selector"
|
|
import autoprefixer from "autoprefixer"
|
|
|
|
export default {
|
|
plugins: [
|
|
purgecss({
|
|
content:
|
|
process.env.NODE_ENV === "production"
|
|
? ["./src/html.tsx", "./src/components/**/*.tsx"]
|
|
: ["./src/**/*.{js,jsx,ts,tsx,html}"],
|
|
css: ["./src/**/*.css"],
|
|
variables: true,
|
|
}),
|
|
autoprefixer(),
|
|
prefixSelector({
|
|
prefix: ":where(.lasuite)",
|
|
transform: function (prefix, selector, prefixedSelector, filePath, rule) {
|
|
if (filePath.includes("dev.css") || filePath.includes("raw-dsfr.css")) {
|
|
return selector
|
|
}
|
|
if (selector.includes(".lasuite") || selector === "html" || selector === ":root") {
|
|
return selector
|
|
}
|
|
if (selector === "body") {
|
|
return `.lasuite`
|
|
}
|
|
return prefixedSelector
|
|
},
|
|
}),
|
|
],
|
|
}
|