-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
vite.config.css.ts
63 lines (61 loc) · 1.69 KB
/
vite.config.css.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { resolve } from 'path'
import { readdirSync } from 'fs'
import postcssPresetEnv from 'postcss-preset-env'
import autoprefixer from 'autoprefixer'
import type { UserConfigExport } from 'vite'
const input: string = resolve(__dirname, 'packages/fighting-theme/src')
export default (): UserConfigExport => {
return {
/** 针对 css 的配置项 */
css: {
/**
* 配置 postcss
*
* @see css.postcss https://cn.vitejs.dev/config/shared-options.html#css-postcss
*/
postcss: {
plugins: [
/**
* 针对一些前沿的 css 进行降级
*
* @see postcss-preset-env https://www.npmjs.com/package/postcss-preset-env
*/
postcssPresetEnv(),
/**
* 自动添加浏览器厂商前缀
*
* @see autoprefixer https://www.npmjs.com/package/autoprefixer
*/
autoprefixer()
]
},
/**
* @see css.preprocessorOptions https://cn.vitejs.dev/config/shared-options.html#css-preprocessoroptions
*/
preprocessorOptions: {
scss: {
additionalData: '$injectedColor: orange;'
}
},
/**
* @see css.modules https://cn.vitejs.dev/config/shared-options.html#css-modules
*/
modules: {
scopeBehaviour: 'local'
}
},
build: {
assetsDir: 'theme',
rollupOptions: {
input: readdirSync(input).map((name): string => {
return `${input}/${name}`
}),
output: {
entryFileNames: 'theme/[name].js',
chunkFileNames: 'theme/[name].js',
assetFileNames: 'theme/[name].[ext]'
}
}
}
}
}