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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. tag.startsWith('picker-view') ||
  34. tag.startsWith('picker-view-column')
  35. );
  36. },
  37. whitespace: 'preserve'
  38. }
  39. }
  40. })
  41. ],
  42. build: {
  43. minify: false,
  44. rollupOptions: {
  45. // 请确保外部化那些你的库中不需要的依赖
  46. external: ['vue', 'vue-router', '@tarojs/taro'],
  47. output: {
  48. banner,
  49. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  50. globals: {
  51. vue: 'Vue'
  52. },
  53. plugins: []
  54. }
  55. },
  56. lib: {
  57. entry: 'src/packages/nutui.taro.vue.build.ts',
  58. name: 'nutui',
  59. fileName: 'nutui',
  60. formats: ['es', 'umd']
  61. }
  62. }
  63. });