vite.config.build.taro.vue.disperse.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import path from 'path';
  4. import fs from 'fs-extra';
  5. import configPkg from './src/config.json';
  6. let input = {};
  7. configPkg.nav.map((item) => {
  8. item.packages.forEach((element) => {
  9. let { name, exclude } = element;
  10. // if (name.toLowerCase().indexOf('calendar') != -1) {
  11. if (exclude != true) {
  12. const filePath = path.join(`./src/packages/__VUE/${name.toLowerCase()}/index.taro.vue`);
  13. input[name] = `./src/packages/__VUE/${name.toLowerCase()}/index${fs.existsSync(filePath) ? '.taro' : ''}.vue`;
  14. }
  15. // }
  16. });
  17. });
  18. export default defineConfig({
  19. resolve: {
  20. alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }]
  21. },
  22. plugins: [
  23. vue({
  24. template: {
  25. compilerOptions: {
  26. isCustomElement: (tag) => {
  27. return (
  28. tag.startsWith('scroll-view') ||
  29. tag.startsWith('swiper') ||
  30. tag.startsWith('swiper-item') ||
  31. tag.startsWith('picker') ||
  32. tag.startsWith('picker-view') ||
  33. tag.startsWith('picker-view-column')
  34. );
  35. },
  36. whitespace: 'preserve'
  37. }
  38. }
  39. })
  40. ],
  41. build: {
  42. minify: false,
  43. lib: {
  44. entry: '',
  45. name: 'index',
  46. // fileName: (format) => format,
  47. formats: ['es']
  48. },
  49. rollupOptions: {
  50. // 请确保外部化那些你的库中不需要的依赖
  51. external: [
  52. 'vue',
  53. 'vue-router',
  54. '@tarojs/taro',
  55. '@/packages/locale',
  56. '@tarojs/components',
  57. '@nutui/icons-vue-taro'
  58. ],
  59. input,
  60. output: {
  61. paths: {
  62. '@/packages/locale': '../locale/lang'
  63. },
  64. dir: path.resolve(__dirname, './dist/packages/_es'),
  65. entryFileNames: '[name].js',
  66. plugins: []
  67. }
  68. },
  69. emptyOutDir: false
  70. }
  71. });