@content-collections/vite 0.1.1 → 0.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/.turbo/turbo-build.log +15 -14
- package/CHANGELOG.md +19 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +34 -13
- package/package.json +2 -2
- package/src/index.ts +50 -15
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.0 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 10ms
|
|
13
|
+
[34mDTS[39m Build start
|
|
14
|
+
[32mDTS[39m ⚡️ Build success in 479ms
|
|
15
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m274.00 B[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @content-collections/vite
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fc22fa3`](https://github.com/sdorra/content-collections/commit/fc22fa384ae06ddd9f8a6ca52ced369f26f15d23) Thanks [@sdorra](https://github.com/sdorra)! - Add option to disable execution
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`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
|
|
12
|
+
|
|
13
|
+
- Updated dependencies []:
|
|
14
|
+
- @content-collections/integrations@0.1.1
|
|
15
|
+
|
|
16
|
+
## 0.1.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`7e0b2d6`](https://github.com/sdorra/content-collections/commit/7e0b2d621f2ab9c1244558ce1c36fe94e08dfdff) Thanks [@sdorra](https://github.com/sdorra)! - Add generated directory to list of allowed files. This required if vite is running with server.fs.strict.
|
|
21
|
+
|
|
3
22
|
## 0.1.1
|
|
4
23
|
|
|
5
24
|
### 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,40 +2,55 @@
|
|
|
2
2
|
import { createBuilder } from "@content-collections/core";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { configureLogging } from "@content-collections/integrations";
|
|
5
|
-
|
|
5
|
+
var defaultOptions = {
|
|
6
|
+
configPath: "content-collections.ts"
|
|
7
|
+
};
|
|
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) {
|
|
18
|
-
|
|
21
|
+
isEnabled = options.isEnabled ? options.isEnabled(config) : true;
|
|
22
|
+
let configPath = resolveConfigPath(
|
|
19
23
|
config.root || process.cwd(),
|
|
20
|
-
|
|
24
|
+
pluginOptions.configPath
|
|
21
25
|
);
|
|
22
|
-
const directory = path.
|
|
23
|
-
|
|
26
|
+
const directory = path.resolve(
|
|
27
|
+
path.dirname(configPath),
|
|
28
|
+
"./.content-collections/generated"
|
|
29
|
+
);
|
|
30
|
+
const configPatch = {
|
|
24
31
|
optimizeDeps: {
|
|
25
32
|
exclude: ["content-collections"]
|
|
26
33
|
},
|
|
27
34
|
resolve: {
|
|
28
35
|
alias: {
|
|
29
|
-
"content-collections":
|
|
30
|
-
directory,
|
|
31
|
-
"./.content-collections/generated/index.js"
|
|
32
|
-
)
|
|
36
|
+
"content-collections": directory
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
};
|
|
40
|
+
if ((config.server?.fs?.allow || []).length > 0) {
|
|
41
|
+
configPatch.server = {
|
|
42
|
+
fs: {
|
|
43
|
+
allow: [directory]
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return configPatch;
|
|
36
48
|
},
|
|
37
49
|
async configResolved(config) {
|
|
38
|
-
|
|
50
|
+
if (!isEnabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let configPath = resolveConfigPath(config.root, pluginOptions.configPath);
|
|
39
54
|
console.log(
|
|
40
55
|
"Starting content-collections with config",
|
|
41
56
|
path.relative(process.cwd(), configPath)
|
|
@@ -45,11 +60,17 @@ function contentCollectionsPlugin(options = {
|
|
|
45
60
|
return;
|
|
46
61
|
},
|
|
47
62
|
async buildStart() {
|
|
63
|
+
if (!isEnabled) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
48
66
|
console.log("Start initial build");
|
|
49
67
|
await builder.build();
|
|
50
68
|
return;
|
|
51
69
|
},
|
|
52
70
|
async configureServer() {
|
|
71
|
+
if (!isEnabled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
53
74
|
console.log("Start watching");
|
|
54
75
|
builder.watch();
|
|
55
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.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"tsup": "^7.2.0",
|
|
21
21
|
"typescript": "^5.3.2",
|
|
22
22
|
"vite": "^5",
|
|
23
|
-
"@content-collections/core": "0.
|
|
23
|
+
"@content-collections/core": "0.3.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"vite": "^5",
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { Builder, createBuilder } from "@content-collections/core";
|
|
2
|
-
import { Plugin } from "vite";
|
|
2
|
+
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;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
configPath: "content-collections.ts",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function resolveConfigPath(root: string, configPath: string) {
|
|
11
16
|
if (!path.isAbsolute(configPath)) {
|
|
12
17
|
configPath = path.resolve(root, configPath);
|
|
13
18
|
}
|
|
@@ -15,37 +20,61 @@ function resolveConfig(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) {
|
|
27
|
-
|
|
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
|
+
|
|
40
|
+
let configPath = resolveConfigPath(
|
|
28
41
|
config.root || process.cwd(),
|
|
29
|
-
|
|
42
|
+
pluginOptions.configPath
|
|
30
43
|
);
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
|
|
45
|
+
const directory = path.resolve(
|
|
46
|
+
path.dirname(configPath),
|
|
47
|
+
"./.content-collections/generated"
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const configPatch: Partial<UserConfig> = {
|
|
33
51
|
optimizeDeps: {
|
|
34
52
|
exclude: ["content-collections"],
|
|
35
53
|
},
|
|
36
54
|
resolve: {
|
|
37
55
|
alias: {
|
|
38
|
-
"content-collections":
|
|
39
|
-
directory,
|
|
40
|
-
"./.content-collections/generated/index.js"
|
|
41
|
-
),
|
|
56
|
+
"content-collections": directory,
|
|
42
57
|
},
|
|
43
58
|
},
|
|
44
59
|
};
|
|
60
|
+
|
|
61
|
+
if ((config.server?.fs?.allow || []).length > 0) {
|
|
62
|
+
// required for Svelte Kit
|
|
63
|
+
configPatch.server = {
|
|
64
|
+
fs: {
|
|
65
|
+
allow: [directory],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return configPatch;
|
|
45
71
|
},
|
|
46
72
|
|
|
47
73
|
async configResolved(config: any) {
|
|
48
|
-
|
|
74
|
+
if (!isEnabled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let configPath = resolveConfigPath(config.root, pluginOptions.configPath);
|
|
49
78
|
console.log(
|
|
50
79
|
"Starting content-collections with config",
|
|
51
80
|
path.relative(process.cwd(), configPath)
|
|
@@ -58,12 +87,18 @@ export default function contentCollectionsPlugin(
|
|
|
58
87
|
},
|
|
59
88
|
|
|
60
89
|
async buildStart() {
|
|
90
|
+
if (!isEnabled) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
61
93
|
console.log("Start initial build");
|
|
62
94
|
await builder.build();
|
|
63
95
|
return;
|
|
64
96
|
},
|
|
65
97
|
|
|
66
98
|
async configureServer() {
|
|
99
|
+
if (!isEnabled) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
67
102
|
console.log("Start watching");
|
|
68
103
|
builder.watch();
|
|
69
104
|
return;
|