- the CSS that included the DSFR excerpt we needed styled some base html tags directly. It might collide with a service CSS already there. Now a postcss plugin applies a CSS prefix to everything - we output in the lib two DSFR file versions: one with prefixed selectors, one raw.
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { resolve } from "path"
|
|
import { defineConfig } from "vite"
|
|
|
|
/*
|
|
* this config file takes care of building the css files
|
|
*
|
|
* it is meant to be run just after the react build, as it doesn't empty the dist/ folder
|
|
* it uses the postcss config in postcss.config.mjs
|
|
*
|
|
* see vite.config.ts for the react files
|
|
*/
|
|
export default defineConfig({
|
|
base: "",
|
|
build: {
|
|
emptyOutDir: false,
|
|
rollupOptions: {
|
|
input: {
|
|
"css-prefixed-dsfr": resolve(__dirname, "src/styles/prefixed-dsfr.css"),
|
|
"css-raw-dsfr": resolve(__dirname, "src/styles/raw-dsfr.css"),
|
|
"css-homepage": resolve(__dirname, "src/styles/homepage.css"),
|
|
"css-gaufre": resolve(__dirname, "src/styles/gaufre.css"),
|
|
"css-homepage-full": resolve(__dirname, "src/styles/homepage-full.css"),
|
|
"css-homepage-gaufre": resolve(__dirname, "src/styles/homepage-gaufre.css"),
|
|
},
|
|
output: {
|
|
assetFileNames: (arg) => {
|
|
if (arg.name?.startsWith("css-") && arg.name.endsWith(".css")) {
|
|
return `css/${arg.name.substring(4)}`
|
|
}
|
|
return `css/assets/[name][extname]`
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|