@tickboxhq/nuxt 0.0.8 → 0.0.10

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.0.8",
7
+ "version": "0.0.10",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs';
1
2
  import { defineNuxtModule, createResolver, resolveAlias, addTemplate, addPlugin, addImports, addComponent, addServerHandler } from '@nuxt/kit';
2
3
 
3
4
  const tickboxModule = defineNuxtModule({
@@ -20,13 +21,22 @@ const tickboxModule = defineNuxtModule({
20
21
  "~~": nuxt.options.rootDir,
21
22
  "@@": nuxt.options.rootDir
22
23
  };
23
- const resolvedConfigPath = resolveAlias(options.configPath ?? "~/consent.config", aliases);
24
+ const resolvedConfigPathWithoutExt = resolveAlias(
25
+ options.configPath ?? "~/consent.config",
26
+ aliases
27
+ );
28
+ const resolvedConfigPath = findExisting(resolvedConfigPathWithoutExt) ?? resolvedConfigPathWithoutExt;
29
+ const templateFile = `${nuxt.options.buildDir}/tickbox-config.mjs`;
24
30
  addTemplate({
25
31
  filename: "tickbox-config.mjs",
26
32
  write: true,
27
33
  getContents: () => `export { default } from ${JSON.stringify(resolvedConfigPath)}
28
34
  `
29
35
  });
36
+ nuxt.hook("nitro:config", (nitroConfig) => {
37
+ nitroConfig.alias = nitroConfig.alias || {};
38
+ nitroConfig.alias["#tickbox-config"] = templateFile;
39
+ });
30
40
  nuxt.options.build.transpile.push("@tickboxhq/vue", "@tickboxhq/core");
31
41
  addPlugin(resolver.resolve("./runtime/plugin"));
32
42
  addImports([
@@ -48,5 +58,14 @@ const tickboxModule = defineNuxtModule({
48
58
  }
49
59
  }
50
60
  });
61
+ function findExisting(basePath) {
62
+ if (existsSync(basePath))
63
+ return basePath;
64
+ for (const ext of [".ts", ".mts", ".mjs", ".js", ".cjs"]) {
65
+ if (existsSync(`${basePath}${ext}`))
66
+ return `${basePath}${ext}`;
67
+ }
68
+ return void 0;
69
+ }
51
70
 
52
71
  export { tickboxModule as default };
@@ -1,6 +1,6 @@
1
1
  import { generateAiTxt } from "@tickboxhq/core";
2
2
  import { defineEventHandler, setHeader } from "h3";
3
- import userConfig from "#build/tickbox-config";
3
+ import userConfig from "#tickbox-config";
4
4
  export default defineEventHandler((event) => {
5
5
  const config = userConfig?.default ?? userConfig;
6
6
  setHeader(event, "Content-Type", "text/plain; charset=utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tickboxhq/nuxt",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Nuxt 3/4 module for Tickbox consent management",
5
5
  "license": "MIT",
6
6
  "homepage": "https://tickbox.dev",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@nuxt/kit": "^3.13.0",
32
- "@tickboxhq/core": "0.0.8",
33
- "@tickboxhq/vue": "0.0.8"
32
+ "@tickboxhq/core": "0.0.10",
33
+ "@tickboxhq/vue": "0.0.10"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "nuxt": "^3.0.0 || ^4.0.0"