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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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) 2021 @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. terserOptions: {
  43. compress: {
  44. drop_console: true,
  45. drop_debugger: true
  46. }
  47. },
  48. rollupOptions: {
  49. // 请确保外部化那些你的库中不需要的依赖
  50. external: ['vue', 'vue-router', '@tarojs/taro'],
  51. output: {
  52. banner,
  53. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  54. globals: {
  55. vue: 'Vue'
  56. }
  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. });