Commit ed8744a4c9cd48d83e2e014bebfa7d3c3489ac33
1 parent
686c344e
perf: add plugin drop console.log in vue3-video-play
Showing
3 changed files
with
80 additions
and
64 deletions
1 | +import { Plugin } from 'vite'; | |
2 | + | |
3 | +export function dropConsoleInVue3VideoPlayPlugin() { | |
4 | + return { | |
5 | + name: 'drop-console-in-vue3-video-play-plugin', | |
6 | + transform(src, id) { | |
7 | + if (id.includes('vue3-video-play')) { | |
8 | + return { | |
9 | + code: src.replaceAll('console.log', ''), | |
10 | + }; | |
11 | + } | |
12 | + }, | |
13 | + } as Plugin; | |
14 | +} | ... | ... |
... | ... | @@ -16,6 +16,7 @@ import { configThemePlugin } from './theme'; |
16 | 16 | import { configImageminPlugin } from './imagemin'; |
17 | 17 | import { configSvgIconsPlugin } from './svgSprite'; |
18 | 18 | import { configHmrPlugin } from './hmr'; |
19 | +import { dropConsoleInVue3VideoPlayPlugin } from './dropConsoleInVue3VideoPlay'; | |
19 | 20 | |
20 | 21 | export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
21 | 22 | const { |
... | ... | @@ -63,6 +64,8 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
63 | 64 | //vite-plugin-theme |
64 | 65 | vitePlugins.push(configThemePlugin(isBuild)); |
65 | 66 | |
67 | + vitePlugins.push(dropConsoleInVue3VideoPlayPlugin()); | |
68 | + | |
66 | 69 | // The following plugins only work in the production environment |
67 | 70 | if (isBuild) { |
68 | 71 | //vite-plugin-imagemin | ... | ... |
... | ... | @@ -2,68 +2,67 @@ |
2 | 2 | * Introduces component library styles on demand. |
3 | 3 | * https://github.com/anncwb/vite-plugin-style-import |
4 | 4 | */ |
5 | - import styleImport from 'vite-plugin-style-import'; | |
5 | +import styleImport from 'vite-plugin-style-import'; | |
6 | 6 | |
7 | - export function configStyleImportPlugin(isBuild: boolean) { | |
8 | - if (!isBuild) { | |
9 | - return []; | |
10 | - } | |
11 | - const styleImportPlugin = styleImport({ | |
12 | - libs: [ | |
13 | - { | |
14 | - libraryName: 'ant-design-vue', | |
15 | - esModule: true, | |
16 | - resolveStyle: (name) => { | |
17 | - // 这里是“子组件”列表,无需额外引入样式文件 | |
18 | - const ignoreList = [ | |
19 | - 'typography-text', | |
20 | - 'typography-title', | |
21 | - 'typography-paragraph', | |
22 | - 'typography-link', | |
23 | - 'anchor-link', | |
24 | - 'sub-menu', | |
25 | - 'menu-item', | |
26 | - 'menu-item-group', | |
27 | - 'dropdown-button', | |
28 | - 'breadcrumb-item', | |
29 | - 'breadcrumb-separator', | |
30 | - 'input-password', | |
31 | - 'input-search', | |
32 | - 'input-group', | |
33 | - 'form-item', | |
34 | - 'radio-group', | |
35 | - 'checkbox-group', | |
36 | - 'layout-sider', | |
37 | - 'layout-content', | |
38 | - 'layout-footer', | |
39 | - 'layout-header', | |
40 | - 'step', | |
41 | - 'select-option', | |
42 | - 'select-opt-group', | |
43 | - 'card-grid', | |
44 | - 'card-meta', | |
45 | - 'collapse-panel', | |
46 | - 'descriptions-item', | |
47 | - 'list-item', | |
48 | - 'list-item-meta', | |
49 | - 'table-column', | |
50 | - 'table-column-group', | |
51 | - 'tab-pane', | |
52 | - 'tab-content', | |
53 | - 'timeline-item', | |
54 | - 'tree-node', | |
55 | - 'skeleton-input', | |
56 | - 'skeleton-avatar', | |
57 | - 'skeleton-title', | |
58 | - 'skeleton-paragraph', | |
59 | - 'skeleton-image', | |
60 | - 'skeleton-button', | |
61 | - ]; | |
62 | - return ignoreList.includes(name) ? '' : `ant-design-vue/es/${name}/style/index`; | |
63 | - }, | |
64 | - }, | |
65 | - ], | |
66 | - }); | |
67 | - return styleImportPlugin; | |
68 | - } | |
69 | - | |
\ No newline at end of file | ||
7 | +export function configStyleImportPlugin(isBuild: boolean) { | |
8 | + if (!isBuild) { | |
9 | + return []; | |
10 | + } | |
11 | + const styleImportPlugin = styleImport({ | |
12 | + libs: [ | |
13 | + { | |
14 | + libraryName: 'ant-design-vue', | |
15 | + esModule: true, | |
16 | + resolveStyle: (name) => { | |
17 | + // 这里是“子组件”列表,无需额外引入样式文件 | |
18 | + const ignoreList = [ | |
19 | + 'typography-text', | |
20 | + 'typography-title', | |
21 | + 'typography-paragraph', | |
22 | + 'typography-link', | |
23 | + 'anchor-link', | |
24 | + 'sub-menu', | |
25 | + 'menu-item', | |
26 | + 'menu-item-group', | |
27 | + 'dropdown-button', | |
28 | + 'breadcrumb-item', | |
29 | + 'breadcrumb-separator', | |
30 | + 'input-password', | |
31 | + 'input-search', | |
32 | + 'input-group', | |
33 | + 'form-item', | |
34 | + 'radio-group', | |
35 | + 'checkbox-group', | |
36 | + 'layout-sider', | |
37 | + 'layout-content', | |
38 | + 'layout-footer', | |
39 | + 'layout-header', | |
40 | + 'step', | |
41 | + 'select-option', | |
42 | + 'select-opt-group', | |
43 | + 'card-grid', | |
44 | + 'card-meta', | |
45 | + 'collapse-panel', | |
46 | + 'descriptions-item', | |
47 | + 'list-item', | |
48 | + 'list-item-meta', | |
49 | + 'table-column', | |
50 | + 'table-column-group', | |
51 | + 'tab-pane', | |
52 | + 'tab-content', | |
53 | + 'timeline-item', | |
54 | + 'tree-node', | |
55 | + 'skeleton-input', | |
56 | + 'skeleton-avatar', | |
57 | + 'skeleton-title', | |
58 | + 'skeleton-paragraph', | |
59 | + 'skeleton-image', | |
60 | + 'skeleton-button', | |
61 | + ]; | |
62 | + return ignoreList.includes(name) ? '' : `ant-design-vue/es/${name}/style/index`; | |
63 | + }, | |
64 | + }, | |
65 | + ], | |
66 | + }); | |
67 | + return styleImportPlugin; | |
68 | +} | ... | ... |