vite.config.build.taro.vue.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { defineConfig } from 'vite';
  2. import vue from '@vitejs/plugin-vue';
  3. import path from 'path';
  4. import config from './package.json';
  5. const banner = `/*!
  6. * ${config.name} v${config.version} ${new Date()}
  7. * (c) 2022 @jdf2e.
  8. * Released under the MIT License.
  9. */`;
  10. export default defineConfig({
  11. resolve: {
  12. alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }]
  13. },
  14. css: {
  15. preprocessorOptions: {
  16. scss: {
  17. // example : additionalData: `@import "./src/design/styles/variables";`
  18. // dont need include file extend .scss
  19. additionalData: `@import "@/packages/styles/variables.scss";@import "@/sites/assets/styles/variables.scss";`
  20. }
  21. }
  22. },
  23. plugins: [
  24. vue({
  25. template: {
  26. compilerOptions: {
  27. isCustomElement: (tag) => {
  28. return (
  29. tag.startsWith('scroll-view') ||
  30. tag.startsWith('swiper') ||
  31. tag.startsWith('swiper-item') ||
  32. tag.startsWith('picker')
  33. );
  34. },
  35. whitespace: 'preserve'
  36. }
  37. }
  38. })
  39. ],
  40. build: {
  41. minify: false,
  42. rollupOptions: {
  43. // 请确保外部化那些你的库中不需要的依赖
  44. external: ['vue', 'vue-router', '@tarojs/taro'],
  45. output: {
  46. banner,
  47. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  48. globals: {
  49. vue: 'Vue'
  50. },
  51. plugins: []
  52. }
  53. },
  54. lib: {
  55. entry: 'src/packages/nutui.taro.vue.build.ts',
  56. name: 'nutui',
  57. fileName: 'nutui',
  58. formats: ['es', 'umd']
  59. }
  60. }
  61. });