/
vite.config.js
55 lines (52 loc) · 1.42 KB
/
vite.config.js
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
const path = require('path')
/**
* @type {import('vite').UserConfig}
*/
module.exports = {
base: './',
build: {
cssTarget: 'chrome61'
},
resolve: {
alias: {
'@': __dirname,
spacefolder: __dirname + '/folder with space'
}
},
css: {
modules: {
generateScopedName: '[name]__[local]___[hash:base64:5]'
// example of how getJSON can be used to generate
// typescript typings for css modules class names
// getJSON(cssFileName, json, _outputFileName) {
// let typings = 'declare const classNames: {\n'
// for (let className in json) {
// typings += ` "${className}": string;\n`
// }
// typings += '};\n'
// typings += 'export default classNames;\n'
// const { join, dirname, basename } = require('path')
// const typingsFile = join(
// dirname(cssFileName),
// basename(cssFileName) + '.d.ts'
// )
// require('fs').writeFileSync(typingsFile, typings)
// },
},
preprocessorOptions: {
scss: {
additionalData: `$injectedColor: orange;`,
importer(url) {
if (url === 'virtual-dep') return { contents: '' }
}
},
styl: {
additionalData: `$injectedColor ?= orange`,
imports: [
'./options/relative-import.styl',
path.join(__dirname, 'options/absolute-import.styl')
]
}
}
}
}