import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import Components from 'unplugin-vue-components/vite' import * as _ from 'lodash' import fs from 'fs-extra' import * as path from 'path' function exist(p) { return fs.existsSync( path.resolve(__dirname, '../theme-chalk/src/' + p + '.scss') ) } // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), Components({ dts: true, resolvers: [ { type: 'component', resolve: (componentName: string) => { if (componentName.startsWith('Ps')) { const name = _.lowerFirst(componentName.slice(2)) return { name: componentName, from: `@princess-ui/components/${name}`, sideEffects: exist(name) ? `@princess-ui/theme-chalk/src/${name}.scss` : undefined, } } }, }, ], }), ], })