@content-collections/vite 0.1.2 → 0.2.1
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/.turbo/turbo-build.log +15 -14
- package/CHANGELOG.md +22 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -5
- package/package.json +5 -5
- package/src/index.ts +28 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @content-collections/vite@0.2.1 build /Users/sdorra/Projects/sdorra/content-collections/packages/vite
|
|
4
|
+
> tsup src/index.ts --format esm --dts -d dist
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v7.2.0
|
|
9
|
+
[34mCLI[39m Target: es2022
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m2.07 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 12ms
|
|
13
|
+
[34mDTS[39m Build start
|
|
14
|
+
[32mDTS[39m ⚡️ Build success in 493ms
|
|
15
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m274.00 B[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @content-collections/vite
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#22](https://github.com/sdorra/content-collections/pull/22) [`17d17b4`](https://github.com/sdorra/content-collections/commit/17d17b4461d7877ce2301ecbca426520e86b8445) Thanks [@sdorra](https://github.com/sdorra)! - Do not proceed if configResolved was not executed before buildStart or configureServer
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @content-collections/integrations@0.1.1
|
|
11
|
+
|
|
12
|
+
## 0.2.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [`fc22fa3`](https://github.com/sdorra/content-collections/commit/fc22fa384ae06ddd9f8a6ca52ced369f26f15d23) Thanks [@sdorra](https://github.com/sdorra)! - Add option to disable execution
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`9de2ba8`](https://github.com/sdorra/content-collections/commit/9de2ba8b34a90d4e70a5f9a3dfd8bb2ced370adb) Thanks [@sdorra](https://github.com/sdorra)! - Add aliases to configuration, even if the plugin is disabled
|
|
21
|
+
|
|
22
|
+
- Updated dependencies []:
|
|
23
|
+
- @content-collections/integrations@0.1.1
|
|
24
|
+
|
|
3
25
|
## 0.1.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
1
|
+
import { UserConfig, Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
type Options = {
|
|
4
4
|
configPath: string;
|
|
5
|
+
isEnabled?: (config: UserConfig) => boolean;
|
|
5
6
|
};
|
|
6
|
-
declare function contentCollectionsPlugin(options?: Options): Plugin;
|
|
7
|
+
declare function contentCollectionsPlugin(options?: Partial<Options>): Plugin;
|
|
7
8
|
|
|
8
|
-
export { contentCollectionsPlugin as default };
|
|
9
|
+
export { Options, contentCollectionsPlugin as default };
|
package/dist/index.js
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
import { createBuilder } from "@content-collections/core";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { configureLogging } from "@content-collections/integrations";
|
|
5
|
+
var defaultOptions = {
|
|
6
|
+
configPath: "content-collections.ts"
|
|
7
|
+
};
|
|
5
8
|
function resolveConfigPath(root, configPath) {
|
|
6
9
|
if (!path.isAbsolute(configPath)) {
|
|
7
10
|
configPath = path.resolve(root, configPath);
|
|
8
11
|
}
|
|
9
12
|
return configPath;
|
|
10
13
|
}
|
|
11
|
-
function contentCollectionsPlugin(options = {
|
|
12
|
-
|
|
13
|
-
}) {
|
|
14
|
+
function contentCollectionsPlugin(options = {}) {
|
|
15
|
+
const pluginOptions = { ...defaultOptions, ...options };
|
|
14
16
|
let builder;
|
|
17
|
+
let isEnabled = false;
|
|
15
18
|
return {
|
|
16
19
|
name: "content-collections",
|
|
17
20
|
config(config) {
|
|
21
|
+
isEnabled = options.isEnabled ? options.isEnabled(config) : true;
|
|
18
22
|
let configPath = resolveConfigPath(
|
|
19
23
|
config.root || process.cwd(),
|
|
20
|
-
|
|
24
|
+
pluginOptions.configPath
|
|
21
25
|
);
|
|
22
26
|
const directory = path.resolve(
|
|
23
27
|
path.dirname(configPath),
|
|
@@ -43,7 +47,10 @@ function contentCollectionsPlugin(options = {
|
|
|
43
47
|
return configPatch;
|
|
44
48
|
},
|
|
45
49
|
async configResolved(config) {
|
|
46
|
-
|
|
50
|
+
if (!isEnabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let configPath = resolveConfigPath(config.root, pluginOptions.configPath);
|
|
47
54
|
console.log(
|
|
48
55
|
"Starting content-collections with config",
|
|
49
56
|
path.relative(process.cwd(), configPath)
|
|
@@ -53,11 +60,17 @@ function contentCollectionsPlugin(options = {
|
|
|
53
60
|
return;
|
|
54
61
|
},
|
|
55
62
|
async buildStart() {
|
|
63
|
+
if (!builder) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
56
66
|
console.log("Start initial build");
|
|
57
67
|
await builder.build();
|
|
58
68
|
return;
|
|
59
69
|
},
|
|
60
70
|
async configureServer() {
|
|
71
|
+
if (!builder) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
61
74
|
console.log("Start watching");
|
|
62
75
|
builder.watch();
|
|
63
76
|
return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@content-collections/vite",
|
|
3
3
|
"description": "Use content-collections with Vite",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"@types/node": "20.x",
|
|
20
20
|
"tsup": "^7.2.0",
|
|
21
21
|
"typescript": "^5.3.2",
|
|
22
|
-
"vite": "^5",
|
|
23
|
-
"@content-collections/core": "0.
|
|
22
|
+
"vite": "^5.2.6",
|
|
23
|
+
"@content-collections/core": "0.4.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"@content-collections/core": "^0.x",
|
|
27
|
+
"vite": "^5"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsup src/index.ts --format esm --dts -d dist"
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,13 @@ import { Plugin, UserConfig } from "vite";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { configureLogging } from "@content-collections/integrations";
|
|
5
5
|
|
|
6
|
-
type Options = {
|
|
6
|
+
export type Options = {
|
|
7
7
|
configPath: string;
|
|
8
|
+
isEnabled?: (config: UserConfig) => boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
configPath: "content-collections.ts",
|
|
8
13
|
};
|
|
9
14
|
|
|
10
15
|
function resolveConfigPath(root: string, configPath: string) {
|
|
@@ -15,18 +20,26 @@ function resolveConfigPath(root: string, configPath: string) {
|
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export default function contentCollectionsPlugin(
|
|
18
|
-
options: Options = {
|
|
19
|
-
configPath: "content-collections.ts",
|
|
20
|
-
}
|
|
23
|
+
options: Partial<Options> = {}
|
|
21
24
|
): Plugin {
|
|
25
|
+
const pluginOptions = { ...defaultOptions, ...options };
|
|
26
|
+
|
|
22
27
|
let builder: Builder;
|
|
28
|
+
let isEnabled = false;
|
|
29
|
+
|
|
23
30
|
return {
|
|
24
31
|
name: "content-collections",
|
|
25
32
|
|
|
26
33
|
config(config) {
|
|
34
|
+
isEnabled = options.isEnabled ? options.isEnabled(config) : true;
|
|
35
|
+
|
|
36
|
+
// even if the plugin is disabled, we need to configure the alias
|
|
37
|
+
// vite is often executed multiple time and the plugin should only
|
|
38
|
+
// run once, but the aliases must be available for all runs
|
|
39
|
+
|
|
27
40
|
let configPath = resolveConfigPath(
|
|
28
41
|
config.root || process.cwd(),
|
|
29
|
-
|
|
42
|
+
pluginOptions.configPath
|
|
30
43
|
);
|
|
31
44
|
|
|
32
45
|
const directory = path.resolve(
|
|
@@ -58,7 +71,10 @@ export default function contentCollectionsPlugin(
|
|
|
58
71
|
},
|
|
59
72
|
|
|
60
73
|
async configResolved(config: any) {
|
|
61
|
-
|
|
74
|
+
if (!isEnabled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let configPath = resolveConfigPath(config.root, pluginOptions.configPath);
|
|
62
78
|
console.log(
|
|
63
79
|
"Starting content-collections with config",
|
|
64
80
|
path.relative(process.cwd(), configPath)
|
|
@@ -71,12 +87,18 @@ export default function contentCollectionsPlugin(
|
|
|
71
87
|
},
|
|
72
88
|
|
|
73
89
|
async buildStart() {
|
|
90
|
+
if (!builder) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
74
93
|
console.log("Start initial build");
|
|
75
94
|
await builder.build();
|
|
76
95
|
return;
|
|
77
96
|
},
|
|
78
97
|
|
|
79
98
|
async configureServer() {
|
|
99
|
+
if (!builder) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
80
102
|
console.log("Start watching");
|
|
81
103
|
builder.watch();
|
|
82
104
|
return;
|