vben
authored
|
1
|
import type { Plugin } from 'vite';
|
vben
authored
|
2
3
4
|
import PurgeIcons from 'vite-plugin-purge-icons';
|
vben
authored
|
5
6
|
// @ts-ignore
import pkg from '../../../package.json';
|
vben
authored
|
7
|
import { ViteEnv } from '../../utils';
|
vben
authored
|
8
9
10
11
|
import { configHtmlPlugin } from './html';
import { configPwaConfig } from './pwa';
import { configMockPlugin } from './mock';
import { configGzipPlugin } from './gzip';
|
vben
authored
|
12
|
import { configStyleImportPlugin } from './styleImport';
|
vben
authored
|
13
|
import { configVisualizerConfig } from './visualizer';
|
vben
authored
|
14
|
import { configThemePlugin } from './theme';
|
vben
authored
|
15
|
import { configImageminPlugin } from './imagemin';
|
vben
authored
|
16
17
|
// gen vite plugins
|
vben
authored
|
18
|
export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) {
|
vben
authored
|
19
|
const vitePlugins: (Plugin | Plugin[])[] = [];
|
vben
authored
|
20
21
|
// vite-plugin-html
|
vben
authored
|
22
23
|
vitePlugins.push(configHtmlPlugin(viteEnv, isBuild));
|
vben
authored
|
24
|
// vite-plugin-mock
|
vben
authored
|
25
26
|
vitePlugins.push(configMockPlugin(viteEnv, isBuild));
|
vben
authored
|
27
28
29
|
// vite-plugin-purge-icons
vitePlugins.push(PurgeIcons());
|
vben
authored
|
30
|
// vite-plugin-style-import
|
vben
authored
|
31
|
vitePlugins.push(configStyleImportPlugin());
|
vben
authored
|
32
|
|
vben
authored
|
33
|
// rollup-plugin-visualizer
|
vben
authored
|
34
|
vitePlugins.push(configVisualizerConfig());
|
vben
authored
|
35
|
|
vben
authored
|
36
37
38
|
//vite-plugin-theme
vitePlugins.push(configThemePlugin());
|
vben
authored
|
39
40
41
42
43
44
45
46
47
48
49
|
if (isBuild) {
//vite-plugin-imagemin
viteEnv.VITE_USE_IMAGEMIN && vitePlugins.push(configImageminPlugin());
// rollup-plugin-gzip
vitePlugins.push(configGzipPlugin(isBuild));
// vite-plugin-pwa
vitePlugins.push(configPwaConfig(viteEnv));
}
|
vben
authored
|
50
|
return vitePlugins;
|
vben
authored
|
51
|
}
|