@varlet/cli 3.7.2-alpha.1733247317826 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,6 +63,7 @@ Also refer to `@varlet/ui` [varlet.config.mjs](https://github.com/varletjs/varle
63
63
  | `pc` | PC side document structure configuration | _[VarletConfigPc](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
64
64
  | `mobile` | Mobile document structure configuration | _[VarletConfigMobile](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
65
65
  | `bundle` | Bundle output options | _{ external: string[], globals: Record<string, string> }_ | `-` |
66
+ | `vitePlugins` | vite plugins | _[Plugin](https://vite.dev/guide/using-plugins.html)[]_ \| `(plugins: Plugin[]) => Plugin[])` | `-` |
66
67
  | `directives` | Component library directive folder name | _string[]_ | `[]` |
67
68
  | `copy` | Copy file configuration | _[CopyPath[]](https://github.com/varletjs/varlet/blob/dev/packages/varlet-vite-plugins/src/copy.ts)_ | `- ` |
68
69
  | `icons` | Font icon packaging related configurations | _[VarletConfigIcons](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts) _ | `-` |
@@ -295,4 +296,4 @@ varlet-cli create
295
296
  ``` shell
296
297
  pnpm config set sharp_binary_host "https://npmmirror.com/mirrors/sharp"
297
298
  pnpm config set sharp_libvips_binary_host "https://npmmirror.com/mirrors/sharp-libvips"
298
- ```
299
+ ```
package/README.zh-CN.md CHANGED
@@ -63,6 +63,7 @@ varlet-cli gen
63
63
  | `pc` | pc 端文档结构配置 | _[VarletConfigPc](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
64
64
  | `mobile` | mobile 端文档结构配置 | _[VarletConfigMobile](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
65
65
  | `bundle` | 组件库编译的捆绑产物配置 | _{ external: string[], globals: Record<string, string> }_ | `-` |
66
+ | `vitePlugins` | vite 插件 | _[Plugin](https://vite.dev/guide/using-plugins.html)[]_ \| `(plugins: Plugin[]) => Plugin[])` | `-` |
66
67
  | `directives` | 组件库指令文件夹名称 | _string[]_ | `[]` |
67
68
  | `copy` | 复制文件配置 | _[CopyPath[]](https://github.com/varletjs/varlet/blob/dev/packages/varlet-vite-plugins/src/copy.ts)_ | `-` |
68
69
  | `icons` | 字体图标打包相关配置 | _[VarletConfigIcons](https://github.com/varletjs/varlet/blob/dev/packages/varlet-cli/src/node/config/varlet.config.ts)_ | `-` |
@@ -294,4 +295,4 @@ varlet-cli create
294
295
  ``` shell
295
296
  pnpm config set sharp_binary_host "https://npmmirror.com/mirrors/sharp"
296
297
  pnpm config set sharp_libvips_binary_host "https://npmmirror.com/mirrors/sharp-libvips"
297
- ```
298
+ ```
@@ -1,6 +1,6 @@
1
1
  import { type VIConfig } from '@varlet/icon-builder';
2
2
  import { type CopyOptions } from '@varlet/vite-plugins';
3
- import { ProxyOptions } from 'vite';
3
+ import { Plugin, ProxyOptions } from 'vite';
4
4
  export interface VarletConfigIcons extends VIConfig {
5
5
  /**
6
6
  * @default true
@@ -171,6 +171,12 @@ export interface VarletConfig {
171
171
  external?: string[];
172
172
  globals?: Record<string, string>;
173
173
  };
174
+ /**
175
+ * @vitePlugins
176
+ * @default `[]`
177
+ * Vite plugins
178
+ */
179
+ vitePlugins?: Plugin[] | ((plugins: Plugin[]) => Plugin[]);
174
180
  /**
175
181
  * @default `[]`
176
182
  * Directive folder name for component library.
@@ -1,4 +1,4 @@
1
- import { InlineConfig } from 'vite';
1
+ import { InlineConfig, Plugin } from 'vite';
2
2
  import { VarletConfig, type VarletConfigHtmlInject } from './varlet.config.js';
3
3
  export declare function getHtmlInject(inject: VarletConfigHtmlInject): {
4
4
  head: {
@@ -12,6 +12,7 @@ export declare function getHtmlInject(inject: VarletConfigHtmlInject): {
12
12
  scriptStart: (string | undefined)[];
13
13
  };
14
14
  };
15
+ export declare function getPlugins(varletConfig: Required<VarletConfig>): Plugin[];
15
16
  export declare function getDevConfig(varletConfig: Required<VarletConfig>): InlineConfig;
16
17
  export declare function getBuildConfig(varletConfig: Required<VarletConfig>): InlineConfig;
17
18
  export interface BundleBuildOptions {
@@ -1,8 +1,9 @@
1
+ import vue from '@vitejs/plugin-vue';
2
+ import jsx from '@vitejs/plugin-vue-jsx';
1
3
  import { SRC_DIR, ES_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, VITE_RESOLVE_EXTENSIONS, EXTENSION_ENTRY, } from '../shared/constant.js';
2
4
  import { markdown, html, inlineCss, copy } from '@varlet/vite-plugins';
3
5
  import { resolve } from 'path';
4
- import vue from '@vitejs/plugin-vue';
5
- import jsx from '@vitejs/plugin-vue-jsx';
6
+ import { isArray } from '@varlet/shared';
6
7
  export function getHtmlInject(inject) {
7
8
  const getContent = (injectKey, position) => inject[injectKey]?.filter((point) => point.position === position).map((point) => point.content) ?? [];
8
9
  return {
@@ -18,6 +19,35 @@ export function getHtmlInject(inject) {
18
19
  },
19
20
  };
20
21
  }
22
+ export function getPlugins(varletConfig) {
23
+ const { vitePlugins = [] } = varletConfig;
24
+ const plugins = [
25
+ vue({
26
+ include: [/\.vue$/, /\.md$/],
27
+ }),
28
+ jsx(),
29
+ markdown({ style: varletConfig?.highlight?.style }),
30
+ copy({ paths: varletConfig?.copy || [] }),
31
+ html({
32
+ data: {
33
+ logo: varletConfig?.logo,
34
+ baidu: varletConfig?.analysis?.baidu,
35
+ pcTitle: varletConfig?.seo?.title ?? '',
36
+ pcDescription: varletConfig?.seo?.description ?? '',
37
+ pcKeywords: varletConfig?.seo?.keywords ?? '',
38
+ pcHtmlInject: getHtmlInject(varletConfig?.pc?.htmlInject || {}),
39
+ mobileTitle: varletConfig?.seo?.title ?? '',
40
+ mobileDescription: varletConfig?.seo?.description ?? '',
41
+ mobileKeywords: varletConfig?.seo?.keywords ?? '',
42
+ mobileHtmlInject: getHtmlInject(varletConfig?.mobile?.htmlInject || {}),
43
+ },
44
+ }),
45
+ ];
46
+ if (isArray(vitePlugins)) {
47
+ return [...plugins, ...vitePlugins];
48
+ }
49
+ return vitePlugins(plugins);
50
+ }
21
51
  export function getDevConfig(varletConfig) {
22
52
  const { alias = {}, host } = varletConfig;
23
53
  const resolveAlias = Object.entries(alias).reduce((resolveAlias, [key, value]) => {
@@ -42,28 +72,7 @@ export function getDevConfig(varletConfig) {
42
72
  proxy: varletConfig?.proxy || {},
43
73
  },
44
74
  publicDir: SITE_PUBLIC_PATH,
45
- plugins: [
46
- vue({
47
- include: [/\.vue$/, /\.md$/],
48
- }),
49
- jsx(),
50
- markdown({ style: varletConfig?.highlight?.style }),
51
- copy({ paths: varletConfig?.copy || [] }),
52
- html({
53
- data: {
54
- logo: varletConfig?.logo,
55
- baidu: varletConfig?.analysis?.baidu,
56
- pcTitle: varletConfig?.seo?.title ?? '',
57
- pcDescription: varletConfig?.seo?.description ?? '',
58
- pcKeywords: varletConfig?.seo?.keywords ?? '',
59
- pcHtmlInject: getHtmlInject(varletConfig?.pc?.htmlInject || {}),
60
- mobileTitle: varletConfig?.seo?.title ?? '',
61
- mobileDescription: varletConfig?.seo?.description ?? '',
62
- mobileKeywords: varletConfig?.seo?.keywords ?? '',
63
- mobileHtmlInject: getHtmlInject(varletConfig?.mobile?.htmlInject || {}),
64
- },
65
- }),
66
- ],
75
+ plugins: getPlugins(varletConfig),
67
76
  };
68
77
  }
69
78
  export function getBuildConfig(varletConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "3.7.2-alpha.1733247317826",
3
+ "version": "3.7.3",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -61,8 +61,8 @@
61
61
  "vite": "5.4.6",
62
62
  "vitest": "2.1.1",
63
63
  "vue": "3.4.21",
64
- "@varlet/shared": "3.7.2-alpha.1733247317826",
65
- "@varlet/vite-plugins": "3.7.2-alpha.1733247317826"
64
+ "@varlet/shared": "3.7.3",
65
+ "@varlet/vite-plugins": "3.7.3"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/babel__core": "^7.20.1",
@@ -74,9 +74,9 @@
74
74
  "@types/node": "^18.7.20",
75
75
  "@types/sharp": "0.31.1",
76
76
  "rimraf": "^5.0.1",
77
- "@varlet/touch-emulator": "3.7.2-alpha.1733247317826",
78
- "@varlet/icons": "3.7.2-alpha.1733247317826",
79
- "@varlet/ui": "3.7.2-alpha.1733247317826"
77
+ "@varlet/icons": "3.7.3",
78
+ "@varlet/touch-emulator": "3.7.3",
79
+ "@varlet/ui": "3.7.3"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@vitest/coverage-istanbul": "2.0.5",
@@ -87,9 +87,9 @@
87
87
  "live-server": "^1.2.1",
88
88
  "vue": "3.4.21",
89
89
  "vue-router": "4.2.0",
90
- "@varlet/touch-emulator": "3.7.2-alpha.1733247317826",
91
- "@varlet/ui": "3.7.2-alpha.1733247317826",
92
- "@varlet/icons": "3.7.2-alpha.1733247317826"
90
+ "@varlet/touch-emulator": "3.7.3",
91
+ "@varlet/ui": "3.7.3",
92
+ "@varlet/icons": "3.7.3"
93
93
  },
94
94
  "scripts": {
95
95
  "dev": "tsc --watch",