-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
42 lines (37 loc) · 1015 Bytes
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { basename } from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import svgr from 'vite-plugin-svgr'
import cssedVitePlugin from 'cssed/vite-plugin'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
svgr(),
cssedVitePlugin()
],
css: {
modules: {
scopeBehaviour: 'global',
localsConvention: 'camelCase',
// https://github.com/css-modules/postcss-modules#generating-scoped-names
generateScopedName: (name, filename, css) => {
let i = css.indexOf("." + name),
line = '' + (parseInt(css.substr(0, i).split(/[\r\n]/).length+'', 10) - 3),
file = basename(filename, ".css")
.replace(/^\./, '')
.split('.module')[0]
.split('.css')[0]
line = line ? `_${line}` : ''
name = name === 'styles' ? '' : `_${name}`
// console.log({filename, file, line, name})
return `_${file}${line}${name}`;
}
}
},
resolve: {
alias: {
crypto: 'rollup-plugin-node-builtins',
}
}
})