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
37 lines
1.1 KiB
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
// import { configMockPlugin } from './mock'
|
|
import { configAutoImportPlugin } from './autoImport'
|
|
import { configAutoComponentsPlugin } from './autocomponents'
|
|
import { configCompressPlugin } from './compress'
|
|
|
|
export function createVitePlugins(viteEnv, isBuild) {
|
|
const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv
|
|
|
|
const vitePlugins = [
|
|
// have to
|
|
vue(),
|
|
// have to
|
|
vueJsx({
|
|
// include: /\.(jsx|tsx)/
|
|
})
|
|
]
|
|
|
|
// unplugin-vue-components
|
|
vitePlugins.push(configAutoComponentsPlugin())
|
|
|
|
// unplugin-auto-import
|
|
vitePlugins.push(configAutoImportPlugin())
|
|
|
|
// // vite-plugin-mock
|
|
// VITE_USE_MOCK && vitePlugins.push(configMockPlugin(isBuild))
|
|
|
|
// The following plugins only work in the production environment
|
|
if (isBuild) {
|
|
// rollup-plugin-gzip
|
|
vitePlugins.push(
|
|
configCompressPlugin(VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE)
|
|
)
|
|
}
|
|
return vitePlugins
|
|
}
|