Change vite config for css
This commit is contained in:
parent
659abb5e21
commit
054a8e00c6
|
@ -3,21 +3,7 @@ import solidPlugin from 'vite-plugin-solid'
|
|||
import ssrPlugin from 'vite-plugin-ssr/plugin'
|
||||
import sassDts from 'vite-plugin-sass-dts'
|
||||
|
||||
const PATH_PREFIX = '/src/'
|
||||
|
||||
const getDevCssClassPrefix = (filename: string): string => {
|
||||
return filename
|
||||
.slice(filename.indexOf(PATH_PREFIX) + PATH_PREFIX.length)
|
||||
.replace('.module.scss', '')
|
||||
.replaceAll(/[/?\\]/g, '-')
|
||||
}
|
||||
|
||||
const devGenerateScopedName = (name: string, filename: string, _css: string) =>
|
||||
getDevCssClassPrefix(filename) + '__' + name
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const isDev = mode === 'development'
|
||||
|
||||
return {
|
||||
envPrefix: 'PUBLIC_',
|
||||
plugins: [solidPlugin({ ssr: true }), ssrPlugin({ includeAssetsImportedByServer: true }), sassDts()],
|
||||
|
@ -25,11 +11,9 @@ export default defineConfig(({ mode }) => {
|
|||
port: 3000
|
||||
},
|
||||
css: {
|
||||
devSourcemap: true,
|
||||
preprocessorOptions: {
|
||||
scss: { additionalData: '@import "src/styles/imports";\n' }
|
||||
},
|
||||
modules: {
|
||||
generateScopedName: isDev ? devGenerateScopedName : undefined
|
||||
}
|
||||
},
|
||||
build: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user