@pubinfo/vite 2.1.3 → 2.1.5

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/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "vite-plugin-fake-server/client";
9
9
  //#region src/plugins/built-in/inject-auto.d.ts
10
10
  interface InjectAutoOptions {
11
11
  id: string;
12
+ enabled?: boolean;
12
13
  }
13
14
  /**
14
15
  * 自动注入代码
@@ -55,7 +56,7 @@ interface PubinfoConfig {
55
56
  /** `@pubinfo/unplugin-openapi` */
56
57
  openapi?: Options;
57
58
  /** `resolver` */
58
- resolver?: ResolverPluginOptions;
59
+ resolver?: Partial<ResolverPluginOptions>;
59
60
  /** devtools */
60
61
  devtools?: Omit<VitePluginVueDevToolsOptions, 'enabled'> & {
61
62
  enabled?: boolean;
@@ -68,6 +69,8 @@ interface ModuleConfig extends PubinfoConfig {
68
69
  * `moduleId`
69
70
  */
70
71
  moduleId: InjectAutoOptions['id'];
72
+ /** 是否开启 `纯净模式` */
73
+ pure?: boolean;
71
74
  }
72
75
  //#endregion
73
76
  //#region src/config/index.d.ts
@@ -77,7 +80,7 @@ interface ModuleConfig extends PubinfoConfig {
77
80
  declare function definePubinfoConfig(config: PubinfoConfig): {
78
81
  vite: UserConfigFnObject;
79
82
  openapi?: _pubinfo_unplugin_openapi0.Options;
80
- resolver?: ResolverPluginOptions;
83
+ resolver?: Partial<ResolverPluginOptions>;
81
84
  devtools?: Omit<vite_plugin_vue_devtools0.VitePluginVueDevToolsOptions, "enabled"> & {
82
85
  enabled?: boolean;
83
86
  };
@@ -89,8 +92,9 @@ declare function definePubinfoConfig(config: PubinfoConfig): {
89
92
  declare function defineModuleConfig(config: ModuleConfig): {
90
93
  vite: UserConfigFnObject;
91
94
  moduleId: InjectAutoOptions["id"];
95
+ pure?: boolean;
92
96
  openapi?: _pubinfo_unplugin_openapi0.Options;
93
- resolver?: ResolverPluginOptions;
97
+ resolver?: Partial<ResolverPluginOptions>;
94
98
  devtools?: Omit<vite_plugin_vue_devtools0.VitePluginVueDevToolsOptions, "enabled"> & {
95
99
  enabled?: boolean;
96
100
  };
package/dist/index.js CHANGED
@@ -152,8 +152,9 @@ function createAppInfo() {
152
152
  * 自动注入代码
153
153
  */
154
154
  function createInjectAuto(options) {
155
- const { id } = options;
155
+ const { id, enabled = true } = options;
156
156
  let entryFiles = [];
157
+ if (!enabled) return { name: "vite-plugin-inject-auto" };
157
158
  return {
158
159
  name: "vite-plugin-inject-auto",
159
160
  enforce: "pre",
@@ -613,7 +614,7 @@ function createUnocss() {
613
614
  //#endregion
614
615
  //#region src/plugins/index.ts
615
616
  function createVitePlugins(viteEnv, isBuild = false, config, type) {
616
- return [
617
+ const vitePlugins = [
617
618
  vue(),
618
619
  vueJsx(),
619
620
  createLegacy(viteEnv),
@@ -628,14 +629,18 @@ function createVitePlugins(viteEnv, isBuild = false, config, type) {
628
629
  createLibResolver(config.resolver),
629
630
  createAppInfo(),
630
631
  createVirtualInspector({ enabled: true }),
631
- createSystemInfo(),
632
- type === "module" ? [
633
- createDTS(),
634
- createInjectCSS(),
635
- createInjectAuto({ id: config.moduleId })
636
- ] : [createCleanBuild()],
637
- isBuild ? createCompression(viteEnv) : null
638
- ].filter(Boolean);
632
+ createSystemInfo()
633
+ ];
634
+ if (type === "module") {
635
+ const moduleConfig = config;
636
+ vitePlugins.push(createDTS(), createInjectCSS(), createInjectAuto({
637
+ id: moduleConfig.moduleId,
638
+ enabled: !moduleConfig.pure
639
+ }));
640
+ }
641
+ if (type === "app") vitePlugins.push(createCleanBuild());
642
+ if (isBuild) vitePlugins.push(createCompression(viteEnv));
643
+ return vitePlugins.filter(Boolean);
639
644
  }
640
645
 
641
646
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/vite",
3
3
  "type": "module",
4
- "version": "2.1.3",
4
+ "version": "2.1.5",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -49,8 +49,8 @@
49
49
  "vite-plugin-fake-server": "^2.2.0",
50
50
  "vite-plugin-lib-inject-css": "^2.2.2",
51
51
  "vite-plugin-vue-devtools": "^8.0.0",
52
- "@pubinfo/devtools": "2.1.3",
53
- "@pubinfo/shared": "2.1.3"
52
+ "@pubinfo/devtools": "2.1.5",
53
+ "@pubinfo/shared": "2.1.5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/fs-extra": "^11.0.4",