vite/packages/playground/css/vite.config.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

const path = require('path')
/**
* @type {import('vite').UserConfig}
*/
module.exports = {
2021-02-11 20:51:21 +00:00
resolve: {
alias: {
'@': __dirname
}
},
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')
]
}
}
}
}