@octohash/vite-config 0.3.4 → 0.5.0

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
@@ -12,7 +12,7 @@ pnpm add -D @octohash/vite-config
12
12
 
13
13
  ## Usage
14
14
 
15
- Automatically detects the project type (app or library) and applies suitable plugins. Manual configuration is rarely needed.
15
+ Provides an application-focused Vite preset with suitable plugins. Manual configuration is rarely needed.
16
16
 
17
17
  ```ts
18
18
  import { defineConfig } from '@octohash/vite-config'
@@ -32,7 +32,7 @@ export default defineConfig({
32
32
 
33
33
  ## Customization
34
34
 
35
- The following is the top-level configuration (OptionsConfig) used to customize the Vite setup. It covers project type detection, alias resolution, common plugins, and both app/library-specific options.
35
+ The following is the top-level configuration (OptionsConfig) used to customize the Vite setup. It covers alias resolution, common plugins, and application-specific options.
36
36
 
37
37
  ```ts
38
38
  interface OptionsConfig {
@@ -42,12 +42,6 @@ interface OptionsConfig {
42
42
  * @default auto-detect based on `command === 'build'`
43
43
  */
44
44
  isBuild?: boolean
45
- /**
46
- * Type of the project
47
- *
48
- * @default auto-detect based on the `index.html` file
49
- */
50
- type?: ProjectType
51
45
  /**
52
46
  * Aliases used to replace values in `import` or `require` statements
53
47
  * Paths are automatically resolved if needed
@@ -71,12 +65,6 @@ interface OptionsConfig {
71
65
  * @default true
72
66
  */
73
67
  license?: boolean | LicensePluginOptions
74
- /**
75
- * https://github.com/originjs/vite-plugin-federation
76
- * Module federation
77
- */
78
- federation?: FederationPluginOptions
79
-
80
68
  // Application Plugin
81
69
  /**
82
70
  * https://github.com/chenxch/vite-plugin-dynamic-base
@@ -89,33 +77,16 @@ interface OptionsConfig {
89
77
  * You can customize the root element and loading template
90
78
  * Use `[app-loading-title]` as a placeholder to dynamically set the document title during loading`
91
79
  *
92
- * @default auto-detect based on `projectType === 'app'`
80
+ * @default true
93
81
  */
94
82
  appLoading?: boolean | AppLoadingPluginOptions
95
83
  /**
96
84
  * Injects metadata using `define`, accessible via `__VITE_APP_METADATA__`.
97
85
  * Includes information such as author, build time, version, and more.
98
86
  *
99
- * @default auto-detect based on `projectType === 'app'`
87
+ * @default true
100
88
  */
101
89
  metadata?: boolean | MetadataPluginOptions
102
- /**
103
- * Generates an import map for the project.
104
- * Based on https://github.com/jspm/vite-plugin-jspm, with extended CDN provider support and options for include/exclude.
105
- *
106
- * @default false
107
- */
108
- importMap?: boolean | ImportMapPluginOptions
109
-
110
- // Library Plugin
111
- /**
112
- * https://github.com/qmhc/vite-plugin-dts
113
- * Generates declaration files from .ts or .vue source files
114
- *
115
- * @default auto-detect based on `projectType === 'lib'`
116
- */
117
- dts?: boolean | DtsPluginOptions
118
-
119
90
  // Vue Plugin
120
91
  /**
121
92
  * Enable Vue support
@@ -153,7 +124,7 @@ interface OptionsVue {
153
124
  * Automatically imports commonly used APIs such as `vue`, `vue-router`, `pinia`, `@vueuse/core`, etc
154
125
  * Also supports auto-importing UI components from libraries like `ant-design-vue`, `element-plus`, etc
155
126
  *
156
- * @default auto-detect based on `projectType === 'app'`
127
+ * @default true
157
128
  */
158
129
  imports?: boolean | VueImportsPluginOptions
159
130
  /**
@@ -161,15 +132,15 @@ interface OptionsVue {
161
132
  * Enabled by default when the project type is `app`
162
133
  * The `directoryAsNamespace` option is enabled by default.
163
134
  *
164
- * @default auto-detect based on `projectType === 'app'`
135
+ * @default true
165
136
  */
166
137
  components?: boolean | VueComponentsPluginOptions
167
138
  /**
168
- * https://github.com/posva/unplugin-vue-router
139
+ * https://router.vuejs.org/guide/file-based-routing.html
169
140
  * Enabled by default when the project type is `app`
170
141
  * Folder(s) to scan for files and generate routes. Defaults to scanning the pages directory.
171
142
  *
172
- * @default auto-detect based on `projectType === 'app'`
143
+ * @default true
173
144
  */
174
145
  pages?: boolean | VuePagesPluginOptions
175
146
  }
@@ -5,6 +5,9 @@
5
5
  }
6
6
 
7
7
  .loading {
8
+ --app-loading-background: #fff;
9
+ --app-loading-foreground: #000;
10
+
8
11
  position: fixed;
9
12
  top: 0;
10
13
  left: 0;
@@ -16,7 +19,8 @@
16
19
  width: 100%;
17
20
  height: 100%;
18
21
  overflow: hidden;
19
- background-color: #f4f7f9;
22
+ color: var(--app-loading-foreground);
23
+ background-color: var(--app-loading-background);
20
24
 
21
25
  /* transition: all 0.8s ease-out; */
22
26
  }
@@ -29,81 +33,86 @@
29
33
  }
30
34
 
31
35
  .dark .loading {
32
- background: #0d0d10;
36
+ --app-loading-background: #000;
37
+ --app-loading-foreground: #fff;
33
38
  }
34
39
 
35
40
  .title {
36
- margin-top: 66px;
41
+ margin-top: 64px;
37
42
  font-size: 28px;
38
43
  font-weight: 600;
39
- color: rgb(0 0 0 / 85%);
40
- }
41
-
42
- .dark .title {
43
- color: #fff;
44
+ color: var(--app-loading-foreground);
44
45
  }
45
46
 
46
47
  .loader {
47
48
  position: relative;
48
- width: 48px;
49
- height: 48px;
49
+ width: 2.5em;
50
+ height: 2.5em;
51
+ font-size: 20px;
52
+ color: var(--app-loading-foreground);
53
+ transform: rotate(165deg);
50
54
  }
51
55
 
52
- .loader::before {
56
+ .loader::before,
57
+ .loader::after {
53
58
  position: absolute;
54
- top: 60px;
55
- left: 0;
56
- width: 48px;
57
- height: 5px;
59
+ top: 50%;
60
+ left: 50%;
61
+ display: block;
62
+ width: 0.5em;
63
+ height: 0.5em;
58
64
  content: '';
59
- background: hsl(var(--primary, 212 100% 45%) / 50%);
60
- border-radius: 50%;
61
- animation: shadow-ani 0.5s linear infinite;
65
+ border-radius: 0.25em;
66
+ transform: translate(-50%, -50%);
62
67
  }
63
68
 
64
- .loader::after {
65
- position: absolute;
66
- top: 0;
67
- left: 0;
68
- width: 100%;
69
- height: 100%;
70
- content: '';
71
- background: hsl(var(--primary, 212 100% 45%));
72
- border-radius: 4px;
73
- animation: jump-ani 0.5s linear infinite;
69
+ .loader::before {
70
+ animation: before8 2s infinite;
74
71
  }
75
72
 
76
- @keyframes jump-ani {
77
- 15% {
78
- border-bottom-right-radius: 3px;
79
- }
73
+ .loader::after {
74
+ animation: after6 2s infinite;
75
+ }
80
76
 
81
- 25% {
82
- transform: translateY(9px) rotate(22.5deg);
77
+ @keyframes before8 {
78
+ 0% {
79
+ width: 0.5em;
80
+ box-shadow: 1em -0.5em currentColor, -1em 0.5em currentColor;
83
81
  }
84
82
 
85
- 50% {
86
- border-bottom-right-radius: 40px;
87
- transform: translateY(18px) scale(1, 0.9) rotate(45deg);
83
+ 35% {
84
+ width: 2.5em;
85
+ box-shadow: 0 -0.5em currentColor, 0 0.5em currentColor;
88
86
  }
89
87
 
90
- 75% {
91
- transform: translateY(9px) rotate(67.5deg);
88
+ 70% {
89
+ width: 0.5em;
90
+ box-shadow: -1em -0.5em currentColor, 1em 0.5em currentColor;
92
91
  }
93
92
 
94
93
  100% {
95
- transform: translateY(0) rotate(90deg);
94
+ box-shadow: 1em -0.5em currentColor, -1em 0.5em currentColor;
96
95
  }
97
96
  }
98
97
 
99
- @keyframes shadow-ani {
100
- 0%,
101
- 100% {
102
- transform: scale(1, 1);
98
+ @keyframes after6 {
99
+ 0% {
100
+ height: 0.5em;
101
+ box-shadow: 0.5em 1em currentColor, -0.5em -1em currentColor;
103
102
  }
104
103
 
105
- 50% {
106
- transform: scale(1.2, 1);
104
+ 35% {
105
+ height: 2.5em;
106
+ box-shadow: 0.5em 0 currentColor, -0.5em 0 currentColor;
107
+ }
108
+
109
+ 70% {
110
+ height: 0.5em;
111
+ box-shadow: 0.5em -1em currentColor, -0.5em 1em currentColor;
112
+ }
113
+
114
+ 100% {
115
+ box-shadow: 0.5em 1em currentColor, -0.5em -1em currentColor;
107
116
  }
108
117
  }
109
118
  </style>
package/dist/index.d.mts CHANGED
@@ -1,195 +1,159 @@
1
- import * as vite from 'vite';
2
- import { AliasOptions, UserConfig, PluginOption } from 'vite';
3
- import { PluginOptions as PluginOptions$1 } from '@intlify/unplugin-vue-i18n';
4
- import { VitePluginFederationOptions } from '@originjs/vite-plugin-federation';
5
- import { Options } from 'unplugin-auto-import/types';
6
- import { Options as Options$1 } from 'unplugin-vue-components';
7
- import { Options as Options$2 } from 'unplugin-vue-router';
8
- import { PluginOptions } from 'vite-plugin-dts';
9
- import { VitePluginVueDevToolsOptions } from 'vite-plugin-vue-devtools';
10
- import { GeneratorOptions } from '@jspm/generator';
1
+ import { AliasOptions, PluginOption, UserConfig } from "vite";
2
+ import { PluginOptions } from "@intlify/unplugin-vue-i18n";
3
+ import { Options } from "unplugin-auto-import/types";
4
+ import { Options as Options$1 } from "unplugin-vue-components";
5
+ import { VitePluginVueDevToolsOptions } from "vite-plugin-vue-devtools";
6
+ import { Options as Options$2 } from "vue-router/unplugin";
11
7
 
8
+ //#region src/plugins/app-loading/index.d.ts
12
9
  interface AppLoadingPluginOptions {
13
- container?: string;
14
- title?: string;
15
- filepath?: string;
10
+ container?: string;
11
+ title?: string;
12
+ filepath?: string;
16
13
  }
17
-
18
- interface ImportMapPluginOptions extends GeneratorOptions {
19
- downloadDeps?: boolean;
20
- debug?: boolean;
21
- defaultProvider?: 'jspm.io' | 'jsdelivr' | 'unpkg' | 'esm.sh';
22
- include?: string[];
23
- exclude?: string[];
24
- }
25
-
14
+ //#endregion
15
+ //#region src/plugins/license.d.ts
26
16
  interface LicensePluginOptions {
27
- name?: string;
28
- author?: string;
29
- version?: string;
30
- description?: string;
31
- homepage?: string;
32
- license?: string;
33
- contact?: string;
34
- copyright?: {
35
- holder?: string;
36
- year?: string | number;
37
- };
17
+ name?: string;
18
+ author?: string;
19
+ version?: string;
20
+ description?: string;
21
+ homepage?: string;
22
+ license?: string;
23
+ contact?: string;
24
+ copyright?: {
25
+ holder?: string;
26
+ year?: string | number;
27
+ };
38
28
  }
39
-
29
+ //#endregion
30
+ //#region src/plugins/metadata.d.ts
40
31
  interface MetadataPluginOptions {
41
- extendMetadata?: Record<string, unknown>;
32
+ extendMetadata?: Record<string, unknown>;
42
33
  }
43
-
44
- type ProjectType = 'app' | 'lib';
34
+ //#endregion
35
+ //#region src/types.d.ts
45
36
  interface CommonPluginOptions {
46
- /**
47
- * https://github.com/KusStar/vite-bundle-visualizer
48
- * By default template path is: ./node_modules/.cache/visualizer/stats.html
49
- *
50
- * @default false
51
- */
52
- visualizer?: boolean | {
53
- help?: boolean;
54
- template?: 'treemap' | 'sunburst' | 'network';
55
- output?: string;
56
- open?: boolean;
57
- config?: string;
58
- };
59
- /**
60
- * Inject license info to output files
61
- * Load license file from `package.json`, if it is a monorepo project, the root `package.json` will also be merged
62
- *
63
- * @default true
64
- */
65
- license?: boolean | LicensePluginOptions;
66
- /**
67
- * https://github.com/originjs/vite-plugin-federation
68
- * Module federation
69
- */
70
- federation?: VitePluginFederationOptions;
37
+ /**
38
+ * https://github.com/KusStar/vite-bundle-visualizer
39
+ * By default template path is: ./node_modules/.cache/visualizer/stats.html
40
+ *
41
+ * @default false
42
+ */
43
+ visualizer?: boolean | {
44
+ help?: boolean;
45
+ template?: 'treemap' | 'sunburst' | 'network';
46
+ output?: string;
47
+ open?: boolean;
48
+ config?: string;
49
+ };
50
+ /**
51
+ * Inject license info to output files
52
+ * Load license file from `package.json`, if it is a monorepo project, the root `package.json` will also be merged
53
+ *
54
+ * @default true
55
+ */
56
+ license?: boolean | LicensePluginOptions;
71
57
  }
72
58
  interface AppPluginOptions {
73
- /**
74
- * https://github.com/chenxch/vite-plugin-dynamic-base
75
- * If you want to build once and deploy to multiple environments, you can enable this plugin to set publicPath at runtime
76
- * You can set like this: `dynamicBase: 'window.__dynamic_base__'`
77
- */
78
- dynamicBase?: string;
79
- /**
80
- * Inject app loading to `index.html`
81
- * You can customize the root element and loading template
82
- * Use `[app-loading-title]` as a placeholder to dynamically set the document title during loading`
83
- *
84
- * @default auto-detect based on `projectType === 'app'`
85
- */
86
- appLoading?: boolean | AppLoadingPluginOptions;
87
- /**
88
- * Injects metadata using `define`, accessible via `__VITE_APP_METADATA__`.
89
- * Includes information such as author, build time, version, and more.
90
- *
91
- * @default auto-detect based on `projectType === 'app'`
92
- */
93
- metadata?: boolean | MetadataPluginOptions;
94
- /**
95
- * Generates an import map for the project.
96
- * Based on https://github.com/jspm/vite-plugin-jspm, with extended CDN provider support and options for include/exclude.
97
- *
98
- * @default false
99
- */
100
- importMap?: boolean | ImportMapPluginOptions;
101
- }
102
- interface LibPluginOptions {
103
- /**
104
- * https://github.com/qmhc/vite-plugin-dts
105
- * Generates declaration files from .ts or .vue source files
106
- *
107
- * @default auto-detect based on `projectType === 'lib'`
108
- */
109
- dts?: boolean | PluginOptions;
59
+ /**
60
+ * https://github.com/chenxch/vite-plugin-dynamic-base
61
+ * If you want to build once and deploy to multiple environments, you can enable this plugin to set publicPath at runtime
62
+ * You can set like this: `dynamicBase: 'window.__dynamic_base__'`
63
+ */
64
+ dynamicBase?: string;
65
+ /**
66
+ * Inject app loading to `index.html`
67
+ * You can customize the root element and loading template
68
+ * Use `[app-loading-title]` as a placeholder to dynamically set the document title during loading`
69
+ *
70
+ * @default true
71
+ */
72
+ appLoading?: boolean | AppLoadingPluginOptions;
73
+ /**
74
+ * Injects metadata using `define`, accessible via `__VITE_APP_METADATA__`.
75
+ * Includes information such as author, build time, version, and more.
76
+ *
77
+ * @default true
78
+ */
79
+ metadata?: boolean | MetadataPluginOptions;
110
80
  }
111
81
  interface OptionsVue {
112
- /**
113
- * https://github.com/vuejs/devtools
114
- * Enable Vue Devtools
115
- *
116
- * @default false
117
- */
118
- devtools?: boolean | VitePluginVueDevToolsOptions;
119
- /**
120
- * https://github.com/intlify/bundle-tools
121
- * Enable Vue I18n
122
- *
123
- * @default false
124
- */
125
- i18n?: boolean | PluginOptions$1;
126
- /**
127
- * https://github.com/unplugin/unplugin-auto-import
128
- * Auto-imports commonly used APIs such as `vue`, `vue-router`, `pinia`, `@vueuse/core`, etc
129
- * Also supports auto-importing UI components from libraries like `ant-design-vue`, `element-plus`, etc
130
- * Files from `src/composables` and `src/utils` will also be auto-imported.
131
- *
132
- * @default auto-detect based on `projectType === 'app'`
133
- */
134
- imports?: boolean | Options;
135
- /**
136
- * https://github.com/unplugin/unplugin-vue-components
137
- * Enabled by default when the project type is `app`
138
- * The `directoryAsNamespace` option is enabled by default.
139
- *
140
- * @default auto-detect based on `projectType === 'app'`
141
- */
142
- components?: boolean | Options$1;
143
- /**
144
- * https://github.com/posva/unplugin-vue-router
145
- * Enabled by default when the project type is `app`
146
- * Folder(s) to scan for files and generate routes. Defaults to scanning the pages directory.
147
- *
148
- * @default auto-detect based on `projectType === 'app'`
149
- */
150
- pages?: boolean | Options$2;
82
+ /**
83
+ * https://github.com/vuejs/devtools
84
+ * Enable Vue Devtools
85
+ *
86
+ * @default false
87
+ */
88
+ devtools?: boolean | VitePluginVueDevToolsOptions;
89
+ /**
90
+ * https://github.com/intlify/bundle-tools
91
+ * Enable Vue I18n
92
+ *
93
+ * @default false
94
+ */
95
+ i18n?: boolean | PluginOptions;
96
+ /**
97
+ * https://github.com/unplugin/unplugin-auto-import
98
+ * Auto-imports commonly used APIs such as `vue`, `vue-router`, `pinia`, `@vueuse/core`, etc
99
+ * Also supports auto-importing UI components from libraries like `ant-design-vue`, `element-plus`, etc
100
+ * Files from `src/composables` and `src/utils` will also be auto-imported.
101
+ *
102
+ * @default true
103
+ */
104
+ imports?: boolean | Options;
105
+ /**
106
+ * https://github.com/unplugin/unplugin-vue-components
107
+ * Enabled by default when the project type is `app`
108
+ * The `directoryAsNamespace` option is enabled by default.
109
+ *
110
+ * @default true
111
+ */
112
+ components?: boolean | Options$1;
113
+ /**
114
+ * https://router.vuejs.org/guide/file-based-routing.html
115
+ * Enabled by default when the project type is `app`
116
+ * Folder(s) to scan for files and generate routes. Defaults to scanning the pages directory.
117
+ *
118
+ * @default true
119
+ */
120
+ pages?: boolean | Options$2;
151
121
  }
152
- interface OptionsConfig extends CommonPluginOptions, AppPluginOptions, LibPluginOptions {
153
- /**
154
- * Whether to build for production
155
- *
156
- * @default auto-detect based on `command === 'build'`
157
- */
158
- isBuild?: boolean;
159
- /**
160
- * Type of the project
161
- *
162
- * @default auto-detect based on the `index.html` file
163
- */
164
- type?: ProjectType;
165
- /**
166
- * Aliases used to replace values in `import` or `require` statements
167
- * Paths are automatically resolved if needed
168
- *
169
- * @default { "@": "./src" }
170
- */
171
- alias?: AliasOptions;
172
- /**
173
- * Enable Vue support
174
- * The goal is to provide an automatic registration mechanism similar to Nuxt in app development.
175
- *
176
- * @default auto-detect based on the dependencies
177
- */
178
- vue?: boolean | OptionsVue;
179
- /**
180
- * Vite configuration override
181
- *
182
- * @default {}
183
- */
184
- vite?: UserConfig;
122
+ interface OptionsConfig extends CommonPluginOptions, AppPluginOptions {
123
+ /**
124
+ * Whether to build for production
125
+ *
126
+ * @default auto-detect based on `command === 'build'`
127
+ */
128
+ isBuild?: boolean;
129
+ /**
130
+ * Aliases used to replace values in `import` or `require` statements
131
+ * Paths are automatically resolved if needed
132
+ *
133
+ * @default { "@": "./src" }
134
+ */
135
+ alias?: AliasOptions;
136
+ /**
137
+ * Enable Vue support
138
+ * The goal is to provide an automatic registration mechanism similar to Nuxt in app development.
139
+ *
140
+ * @default auto-detect based on the dependencies
141
+ */
142
+ vue?: boolean | OptionsVue;
143
+ /**
144
+ * Vite configuration override
145
+ *
146
+ * @default {}
147
+ */
148
+ vite?: UserConfig;
185
149
  }
186
150
  interface ConditionPlugin {
187
- condition?: boolean;
188
- plugins: () => PluginOption[] | PromiseLike<PluginOption[]>;
151
+ condition?: boolean;
152
+ plugins: () => PluginOption[] | PromiseLike<PluginOption[]>;
189
153
  }
190
154
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
191
-
192
- declare function defineConfig(options: OptionsConfig): vite.UserConfigFnPromise;
193
-
194
- export { defineConfig };
195
- export type { AppPluginOptions, CommonPluginOptions, ConditionPlugin, LibPluginOptions, OptionsConfig, OptionsVue, ProjectType, ResolvedOptions };
155
+ //#endregion
156
+ //#region src/index.d.ts
157
+ declare function defineConfig(options: OptionsConfig): import("vite").UserConfigFnPromise;
158
+ //#endregion
159
+ export { AppPluginOptions, CommonPluginOptions, ConditionPlugin, OptionsConfig, OptionsVue, ResolvedOptions, defineConfig };