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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. define: {
  12. 'process.env.TARO_ENV': 'process.env.TARO_ENV'
  13. },
  14. resolve: {
  15. alias: [{ find: '@', replacement: path.resolve(__dirname, './src') }]
  16. },
  17. css: {
  18. preprocessorOptions: {
  19. scss: {
  20. // example : additionalData: `@import "./src/design/styles/variables";`
  21. // dont need include file extend .scss
  22. additionalData: `@import "@/packages/styles/variables.scss";@import "@/sites/assets/styles/variables.scss";`
  23. }
  24. }
  25. },
  26. plugins: [
  27. vue({
  28. template: {
  29. compilerOptions: {
  30. isCustomElement: (tag) => {
  31. return (
  32. tag.startsWith('swiper') ||
  33. tag.startsWith('swiper-item') ||
  34. tag.startsWith('scroll-view') ||
  35. tag.startsWith('picker') ||
  36. tag.startsWith('picker-view') ||
  37. tag.startsWith('picker-view-column')
  38. );
  39. },
  40. whitespace: 'preserve'
  41. }
  42. }
  43. })
  44. ],
  45. build: {
  46. minify: false,
  47. rollupOptions: {
  48. // 请确保外部化那些你的库中不需要的依赖
  49. external: ['vue', 'vue-router', '@tarojs/taro', '@tarojs/components'],
  50. output: {
  51. banner,
  52. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  53. globals: {
  54. vue: 'Vue'
  55. },
  56. plugins: []
  57. }
  58. },
  59. lib: {
  60. entry: 'src/packages/nutui.taro.vue.build.ts',
  61. name: 'nutui',
  62. fileName: 'nutui',
  63. formats: ['es', 'umd']
  64. }
  65. }
  66. });