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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // 开发模式取消压缩混淆
  26. minify: false,
  27. rollupOptions: {
  28. // 请确保外部化那些你的库中不需要的依赖
  29. external: ['vue', 'vue-router', '@tarojs/taro'],
  30. output: {
  31. banner,
  32. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  33. globals: {
  34. vue: 'Vue'
  35. }
  36. }
  37. },
  38. lib: {
  39. entry: 'src/packages/nutui.taro.vue.ts',
  40. name: 'nutui',
  41. formats: ['es', 'umd']
  42. }
  43. }
  44. });