@content-collections/vite 0.1.0 → 0.1.2

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @content-collections/vite@0.0.0 build /Users/sdorra/Projects/sdorra/content-collections/packages/vite
2
+ > @content-collections/vite@0.1.1 build /Users/sdorra/Projects/sdorra/content-collections/packages/vite
3
3
  > tsup src/index.ts --format esm --dts -d dist
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -7,8 +7,8 @@ CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v7.2.0
8
8
  CLI Target: es2022
9
9
  ESM Build start
10
- ESM dist/index.js 1.56 KB
11
- ESM ⚡️ Build success in 11ms
10
+ ESM dist/index.js 1.74 KB
11
+ ESM ⚡️ Build success in 9ms
12
12
  DTS Build start
13
- DTS ⚡️ Build success in 510ms
13
+ DTS ⚡️ Build success in 489ms
14
14
  DTS dist/index.d.ts 195.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @content-collections/vite
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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.
8
+
9
+ ## 0.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`5c7022f`](https://github.com/sdorra/content-collections/commit/5c7022f630a9194ff5579f792c06dcca31611cd5) Thanks [@sdorra](https://github.com/sdorra)! - Update version range of core package
14
+
15
+ - Updated dependencies [[`5c7022f`](https://github.com/sdorra/content-collections/commit/5c7022f630a9194ff5579f792c06dcca31611cd5)]:
16
+ - @content-collections/integrations@0.1.1
17
+
3
18
  ## 0.1.0
4
19
 
5
20
  ### Minor Changes
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createBuilder } from "@content-collections/core";
3
3
  import path from "path";
4
4
  import { configureLogging } from "@content-collections/integrations";
5
- function resolveConfig(root, configPath) {
5
+ function resolveConfigPath(root, configPath) {
6
6
  if (!path.isAbsolute(configPath)) {
7
7
  configPath = path.resolve(root, configPath);
8
8
  }
@@ -15,27 +15,35 @@ function contentCollectionsPlugin(options = {
15
15
  return {
16
16
  name: "content-collections",
17
17
  config(config) {
18
- let configPath = resolveConfig(
18
+ let configPath = resolveConfigPath(
19
19
  config.root || process.cwd(),
20
20
  options.configPath
21
21
  );
22
- const directory = path.dirname(configPath);
23
- return {
22
+ const directory = path.resolve(
23
+ path.dirname(configPath),
24
+ "./.content-collections/generated"
25
+ );
26
+ const configPatch = {
24
27
  optimizeDeps: {
25
28
  exclude: ["content-collections"]
26
29
  },
27
30
  resolve: {
28
31
  alias: {
29
- "content-collections": path.resolve(
30
- directory,
31
- "./.content-collections/generated/index.js"
32
- )
32
+ "content-collections": directory
33
33
  }
34
34
  }
35
35
  };
36
+ if ((config.server?.fs?.allow || []).length > 0) {
37
+ configPatch.server = {
38
+ fs: {
39
+ allow: [directory]
40
+ }
41
+ };
42
+ }
43
+ return configPatch;
36
44
  },
37
45
  async configResolved(config) {
38
- let configPath = resolveConfig(config.root, options.configPath);
46
+ let configPath = resolveConfigPath(config.root, options.configPath);
39
47
  console.log(
40
48
  "Starting content-collections with config",
41
49
  path.relative(process.cwd(), configPath)
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.0",
4
+ "version": "0.1.2",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -13,18 +13,18 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@content-collections/integrations": "0.1.0"
16
+ "@content-collections/integrations": "0.1.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/node": "20.x",
20
20
  "tsup": "^7.2.0",
21
21
  "typescript": "^5.3.2",
22
22
  "vite": "^5",
23
- "@content-collections/core": "0.1.1"
23
+ "@content-collections/core": "0.2.0"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "vite": "^5",
27
- "@content-collections/core": "0.1.1"
27
+ "@content-collections/core": "^0.x"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup src/index.ts --format esm --dts -d dist"
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
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
 
@@ -7,7 +7,7 @@ type Options = {
7
7
  configPath: string;
8
8
  };
9
9
 
10
- function resolveConfig(root: string, configPath: string) {
10
+ function resolveConfigPath(root: string, configPath: string) {
11
11
  if (!path.isAbsolute(configPath)) {
12
12
  configPath = path.resolve(root, configPath);
13
13
  }
@@ -24,28 +24,41 @@ export default function contentCollectionsPlugin(
24
24
  name: "content-collections",
25
25
 
26
26
  config(config) {
27
- let configPath = resolveConfig(
27
+ let configPath = resolveConfigPath(
28
28
  config.root || process.cwd(),
29
29
  options.configPath
30
30
  );
31
- const directory = path.dirname(configPath);
32
- return {
31
+
32
+ const directory = path.resolve(
33
+ path.dirname(configPath),
34
+ "./.content-collections/generated"
35
+ );
36
+
37
+ const configPatch: Partial<UserConfig> = {
33
38
  optimizeDeps: {
34
39
  exclude: ["content-collections"],
35
40
  },
36
41
  resolve: {
37
42
  alias: {
38
- "content-collections": path.resolve(
39
- directory,
40
- "./.content-collections/generated/index.js"
41
- ),
43
+ "content-collections": directory,
42
44
  },
43
45
  },
44
46
  };
47
+
48
+ if ((config.server?.fs?.allow || []).length > 0) {
49
+ // required for Svelte Kit
50
+ configPatch.server = {
51
+ fs: {
52
+ allow: [directory],
53
+ },
54
+ };
55
+ }
56
+
57
+ return configPatch;
45
58
  },
46
59
 
47
60
  async configResolved(config: any) {
48
- let configPath = resolveConfig(config.root, options.configPath);
61
+ let configPath = resolveConfigPath(config.root, options.configPath);
49
62
  console.log(
50
63
  "Starting content-collections with config",
51
64
  path.relative(process.cwd(), configPath)
package/README.md DELETED
@@ -1,44 +0,0 @@
1
- ---
2
- title: Vite Integration
3
- ---
4
-
5
- 1. Install required packages:
6
-
7
- We have to install the following packages:
8
-
9
- - `@content-collections/core`
10
- - `@content-collections/vite`
11
-
12
- ```bash
13
- pnpm add -D @content-collections/core @content-collections/vite
14
- ```
15
-
16
- 1. Adjust your `tsconfig.json`:
17
-
18
- ```json
19
- {
20
- "compilerOptions": {
21
- // ...
22
- "paths": {
23
- "content-collections": ["./.content-collections/generated"]
24
- }
25
- }
26
- }
27
- ```
28
-
29
- We require a path alias for the generated files.
30
- This is necessary because we will generate the files in the `.content-collections/generated` folder.
31
-
32
- 1. Modify your `vite.config.ts`:
33
-
34
- ```ts
35
- import { defineConfig } from "vite";
36
- import contentCollections from "@content-collections/vite";
37
-
38
- export default defineConfig({
39
- plugins: [/** other plugins */, contentCollections()],
40
- });
41
-
42
- ```
43
-
44
- Add the Content Collections plugin to your Vite config.