You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

2 months ago
  1. import vue from '@vitejs/plugin-vue'
  2. import vueJsx from '@vitejs/plugin-vue-jsx'
  3. // import { configMockPlugin } from './mock'
  4. import { configAutoImportPlugin } from './autoImport'
  5. import { configAutoComponentsPlugin } from './autocomponents'
  6. import { configCompressPlugin } from './compress'
  7. export function createVitePlugins(viteEnv, isBuild) {
  8. const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv
  9. const vitePlugins = [
  10. // have to
  11. vue(),
  12. // have to
  13. vueJsx({
  14. // include: /\.(jsx|tsx)/
  15. })
  16. ]
  17. // unplugin-vue-components
  18. vitePlugins.push(configAutoComponentsPlugin())
  19. // unplugin-auto-import
  20. vitePlugins.push(configAutoImportPlugin())
  21. // // vite-plugin-mock
  22. // VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild))
  23. // The following plugins only work in the production environment
  24. if (isBuild) {
  25. // rollup-plugin-gzip
  26. vitePlugins.push(
  27. configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE)
  28. )
  29. }
  30. return vitePlugins
  31. }