braindrops.nicwands.com/shared/vite.config.js
2026-07-17 11:24:36 -04:00

44 lines
1.3 KiB
JavaScript

import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import config from './config.js'
import { toSass } from './libs/sass/index.js'
export default defineConfig({
plugins: [vue()],
server: {
port: 3000,
},
resolve: {
alias: {
'@shared': fileURLToPath(new URL('.', import.meta.url)),
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
additionalData:
'@use "@shared/styles/_functions.scss" as *; @use "@shared/styles/_font-style.scss" as *;',
functions: {
'get($keys)': function (keys) {
keys = keys.toString().replace(/['"]+/g, '').split('.')
let result = config
for (let i = 0; i < keys.length; i++) {
result = result[keys[i]]
}
return toSass(result)
},
'getColors()': function () {
return toSass(config.colors)
},
'getThemes()': function () {
return toSass(config.themes)
},
},
},
},
},
})