123456789101112131415161718192021222324252627282930313233343536 |
- import { defineConfig } from 'vite';
- import vue from '@vitejs/plugin-vue';
- import VitePluginStyleInject from 'vite-plugin-style-inject';
- const componentName = process.env.name;
- console.log('当前组件名称:', componentName)
- export default defineConfig({
- plugins: [
- vue(),
- VitePluginStyleInject()
- ],
- build: {
- lib: {
- entry: 'index.js',
- name: 'MyComponentLibrary',
- fileName: (format) => `index.${format}.js`,
- },
- rollupOptions: {
- external: ['vue'],
- output: {
- globals: {
- vue: 'Vue'
- },
- },
- input: componentName
- ? {
- [componentName]: `./${componentName}/index.js`,
- }
- : {},
- },
- outDir: `./${componentName}/dist`,
- },
- });
|