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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: [vue()],
  24. build: {
  25. minify: false,
  26. terserOptions: {
  27. compress: {
  28. drop_console: true,
  29. drop_debugger: true
  30. }
  31. },
  32. rollupOptions: {
  33. // 请确保外部化那些你的库中不需要的依赖
  34. external: ['vue', 'vue-router', '@tarojs/taro', 'pinyin'],
  35. output: {
  36. banner,
  37. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  38. globals: {
  39. vue: 'Vue'
  40. }
  41. }
  42. },
  43. lib: {
  44. entry: 'src/packages/nutui.taro.vue.build.ts',
  45. name: 'nutui',
  46. fileName: 'nutui',
  47. formats: ['es', 'umd']
  48. }
  49. }
  50. });