vite.config.build.locale.ts 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { defineConfig } from 'vite';
  2. import path from 'path';
  3. import config from './package.json';
  4. import vue from '@vitejs/plugin-vue';
  5. const banner = `/*!
  6. * ${config.name} v${config.version} ${new Date()}
  7. * (c) 2022 @jdf2e.
  8. * Released under the MIT License.
  9. */`;
  10. let input = {
  11. index: `./src/packages/locale/index`
  12. };
  13. // 动态读取file name
  14. ['zh-CN', 'zh-TW', 'en-US', 'id-ID'].map((file) => {
  15. input[file] = `./src/packages/locale/lang/${file}`;
  16. });
  17. export default defineConfig({
  18. plugins: [vue()],
  19. build: {
  20. minify: true,
  21. lib: {
  22. entry: '',
  23. name: 'index',
  24. // fileName: (format) => format,
  25. formats: ['es']
  26. },
  27. rollupOptions: {
  28. // 请确保外部化那些你的库中不需要的依赖
  29. external: ['vue'],
  30. input,
  31. output: {
  32. banner,
  33. dir: path.resolve(__dirname, './dist/packages/locale/lang'),
  34. entryFileNames: '[name].js',
  35. plugins: []
  36. }
  37. },
  38. emptyOutDir: false
  39. }
  40. });