config-vp 1.1.0 → 1.2.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
@@ -47,13 +47,13 @@ This also pulls in everything the config needs (`oxlint`, `oxfmt`, and the lint
47
47
  **2. Create `vite.config.ts`:**
48
48
 
49
49
  ```ts
50
- import { defineConfig } from 'config-vp';
50
+ import { defineVitePlusConfig } from 'config-vp';
51
51
 
52
- const config = defineConfig({ type: 'lib' });
52
+ const config = defineVitePlusConfig({ type: 'lib' });
53
53
  export default config;
54
54
  ```
55
55
 
56
- > **Important:** Assign to a `const` and export it — don't write `export default defineConfig(...)` inline. `vp` reads your default export statically to discover tasks; a direct call hides them and `vp run` reports "Task not found". See [Troubleshooting](#troubleshooting).
56
+ > **Important:** Assign to a `const` and export it — don't write `export default defineVitePlusConfig(...)` inline. `vp` reads your default export statically to discover tasks; a direct call hides them and `vp run` reports "Task not found". See [Troubleshooting](#troubleshooting).
57
57
 
58
58
  **3. Run something:**
59
59
 
@@ -83,38 +83,32 @@ Set `type` to match what you're building. It drives Vue lint rules, library pack
83
83
 
84
84
  Customize with the `config` hook — it receives the fully built config (see [Customizing](#customizing)).
85
85
 
86
- **Library** — dual ESM + CJS output:
86
+ **Plain package** — lint + format + tests only, no build/dev (e.g. a config or scripts-only package). Just call `defineVitePlusConfig()` with no `type`:
87
87
 
88
88
  ```ts
89
- import { defineConfig } from 'config-vp';
89
+ import { defineVitePlusConfig } from 'config-vp';
90
90
 
91
- const config = defineConfig({
92
- type: 'lib',
93
- config: c => {
94
- c.pack = {
95
- ...c.pack,
96
- entry: ['src/index.ts'],
97
- format: ['esm', 'cjs'],
98
- };
99
- },
100
- });
91
+ const config = defineVitePlusConfig();
101
92
  export default config;
102
93
  ```
103
94
 
104
- **Vue library** — same, with `type: 'lib:vue'` for SFC/template lint rules.
95
+ **Vue app** — a Vite-based Vue application, with plugins and a path alias:
105
96
 
106
97
  ```ts
107
- import { defineConfig } from 'config-vp';
98
+ import vue from '@vitejs/plugin-vue';
99
+ import { defineVitePlusConfig } from 'config-vp';
100
+ import { fileURLToPath, URL } from 'node:url';
101
+ import vueDevTools from 'vite-plugin-vue-devtools';
108
102
 
109
- const config = defineConfig({
110
- type: 'lib:vue',
111
- config: c => {
112
- c.pack = {
113
- ...c.pack,
114
- entry: ['src/index.ts'],
115
- format: ['esm', 'cjs'],
116
- };
117
- },
103
+ const config = defineVitePlusConfig({
104
+ type: 'vue',
105
+ config: c => ({
106
+ ...c,
107
+ plugins: [vue(), vueDevTools()],
108
+ resolve: {
109
+ alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
110
+ },
111
+ }),
118
112
  });
119
113
  export default config;
120
114
  ```
@@ -124,9 +118,9 @@ export default config;
124
118
  ```ts
125
119
  // nuxt.config.vite.ts
126
120
  import type { NuxtConfig } from 'nuxt/schema';
127
- import { defineConfig } from 'config-vp';
121
+ import { defineVitePlusConfig } from 'config-vp';
128
122
 
129
- export const vite = defineConfig({
123
+ export const vite = defineVitePlusConfig({
130
124
  type: 'nuxt:spa', // or 'nuxt:ssr'
131
125
  config: c => {
132
126
  // any Vite/vite-plus options the app needs, e.g. plugins, define, test, …
@@ -144,12 +138,39 @@ export default defineNuxtConfig({ vite });
144
138
 
145
139
  The `export const vite = …` form is itself a const export, so `vp` discovers any tasks you add in the `config` hook.
146
140
 
147
- **Plain package** — lint + format + tests only, no build/dev (e.g. a config or scripts-only package). Just call `defineConfig()` with no `type`:
141
+ **Library** — dual ESM + CJS output:
148
142
 
149
143
  ```ts
150
- import { defineConfig } from 'config-vp';
144
+ import { defineVitePlusConfig } from 'config-vp';
151
145
 
152
- const config = defineConfig();
146
+ const config = defineVitePlusConfig({
147
+ type: 'lib',
148
+ config: c => {
149
+ c.pack = {
150
+ ...c.pack,
151
+ entry: ['src/index.ts'],
152
+ format: ['esm', 'cjs'],
153
+ };
154
+ },
155
+ });
156
+ export default config;
157
+ ```
158
+
159
+ **Vue library** — same, with `type: 'lib:vue'` for SFC/template lint rules.
160
+
161
+ ```ts
162
+ import { defineVitePlusConfig } from 'config-vp';
163
+
164
+ const config = defineVitePlusConfig({
165
+ type: 'lib:vue',
166
+ config: c => {
167
+ c.pack = {
168
+ ...c.pack,
169
+ entry: ['src/index.ts'],
170
+ format: ['esm', 'cjs'],
171
+ };
172
+ },
173
+ });
153
174
  export default config;
154
175
  ```
155
176
 
@@ -197,7 +218,7 @@ Run any task with `vp run <task>`. Tasks are cached and run in dependency order
197
218
  There's one customization hook: **`config`**. It receives the fully built config — lint, fmt, staged, run tasks, and (for `lib*`) pack, all already populated — and you change whatever you want with plain JS. Mutate it in place, or return a new object (a returned value wins; otherwise the mutated argument is used). It's fully typed, so autocomplete shows you exactly what's there.
198
219
 
199
220
  ```ts
200
- const config = defineConfig({
221
+ const config = defineVitePlusConfig({
201
222
  type: 'lib',
202
223
  config: c => {
203
224
  c.pack = {
@@ -220,7 +241,7 @@ The hook works two ways — use whichever reads better:
220
241
 
221
242
  ```ts
222
243
  // Mutate in place and return nothing — best for a few targeted tweaks:
223
- defineConfig({
244
+ defineVitePlusConfig({
224
245
  type: 'lib',
225
246
  config: c => {
226
247
  c.pack = {
@@ -231,7 +252,7 @@ defineConfig({
231
252
  });
232
253
 
233
254
  // Return a new object — best when you want to build the result explicitly:
234
- defineConfig({
255
+ defineVitePlusConfig({
235
256
  type: 'lib',
236
257
  config: c => ({
237
258
  ...c,
@@ -250,7 +271,7 @@ A returned value wins; if you return nothing, the mutated argument is used. Don'
250
271
  Anything in a normal Vite / vite-plus config — `plugins`, `resolve`, `define`, `server`, `optimizeDeps`, `worker`, `test`, `build`, extra `run.tasks`, … — is just a field you set in the hook. Nothing config-vp-specific to learn; keep writing Vite config.
251
272
 
252
273
  ```ts
253
- const config = defineConfig({
274
+ const config = defineVitePlusConfig({
254
275
  type: 'nuxt:spa',
255
276
  config: c => {
256
277
  c.plugins = [...tailwindcss()];
@@ -279,13 +300,13 @@ export default config;
279
300
  `ignorePatterns` sets the ignore globs for **both** the linter and the formatter. Pass an array to set the whole list, or a function to derive it from the built-in defaults:
280
301
 
281
302
  ```ts
282
- defineConfig({
303
+ defineVitePlusConfig({
283
304
  type: 'lib',
284
305
  // add to the defaults:
285
306
  ignorePatterns: defaults => [...defaults, 'generated/**', 'vendor/**'],
286
307
  });
287
308
 
288
- defineConfig({
309
+ defineVitePlusConfig({
289
310
  type: 'lib',
290
311
  // …or set the list outright:
291
312
  ignorePatterns: ['only-this/**'],
@@ -297,7 +318,7 @@ defineConfig({
297
318
  A `lib*` type includes packaging by default. To skip it, delete `pack` in the hook:
298
319
 
299
320
  ```ts
300
- defineConfig({
321
+ defineVitePlusConfig({
301
322
  type: 'lib',
302
323
  config: c => {
303
324
  delete c.pack;
@@ -327,7 +348,7 @@ The base list applied to both linting and formatting (override or extend it via
327
348
 
328
349
  ## API
329
350
 
330
- The package exports a single function, `defineConfig`, plus the types `ConfigOptions` (its argument), `ProjectType`, and `ResolvedConfig` (the value passed to the `config` hook).
351
+ The package exports a single function, `defineVitePlusConfig`, plus the types `ConfigOptions` (its argument), `ProjectType`, and `ResolvedConfig` (the value passed to the `config` hook).
331
352
 
332
353
  ## Troubleshooting
333
354
 
@@ -337,10 +358,10 @@ Your config almost certainly uses an inline default export. `vp` discovers tasks
337
358
 
338
359
  ```ts
339
360
  // ❌ tasks are invisible to `vp run`
340
- export default defineConfig({ type: 'lib' });
361
+ export default defineVitePlusConfig({ type: 'lib' });
341
362
 
342
363
  // ✅ assign, then export
343
- const config = defineConfig({ type: 'lib' });
364
+ const config = defineVitePlusConfig({ type: 'lib' });
344
365
  export default config;
345
366
  ```
346
367
 
package/dist/index.d.mts CHANGED
@@ -36,6 +36,6 @@ interface ConfigOptions {
36
36
  */
37
37
  config?: (config: ResolvedConfig) => ResolvedConfig | undefined;
38
38
  }
39
- declare function defineConfig(options?: ConfigOptions): UserConfig;
39
+ declare function defineVitePlusConfig(options?: ConfigOptions): UserConfig;
40
40
  //#endregion
41
- export { ConfigOptions, ProjectType, ResolvedConfig, defineConfig };
41
+ export { ConfigOptions, ProjectType, ResolvedConfig, defineVitePlusConfig };
package/dist/index.mjs CHANGED
@@ -652,7 +652,7 @@ function mergeLintConfigs(...configs) {
652
652
  return merged;
653
653
  });
654
654
  }
655
- function defineConfig(options = {}) {
655
+ function defineVitePlusConfig(options = {}) {
656
656
  const t = options.type;
657
657
  const isVue = t === "lib:vue" || t === "lib:nuxt" || t === "vue" || t === "nuxt:spa" || t === "nuxt:ssr";
658
658
  const isLib = t === "lib" || t === "lib:vue" || t === "lib:nuxt";
@@ -680,4 +680,4 @@ function defineConfig(options = {}) {
680
680
  return options.config ? options.config(base) ?? base : base;
681
681
  }
682
682
  //#endregion
683
- export { defineConfig };
683
+ export { defineVitePlusConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "config-vp",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Shared vite-plus configuration — opinionated defaults for linting, formatting, task running, staged checks, and VSCode setup. Optional Vue and pack layers with deep-merge overrides.",
5
5
  "keywords": [
6
6
  "config",