@model-w/preset-nuxt3 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/index.ts +73 -6
  2. package/package.json +16 -15
package/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { resolve } from "node:path";
1
2
  // @ts-ignore
2
3
  import { defineNuxtConfig } from "nuxt/config";
3
4
  import { defu } from "defu";
@@ -137,17 +138,66 @@ class EnvManager {
137
138
  }
138
139
 
139
140
  export interface ModelWConfig {
141
+ /**
142
+ * Site name for display purposes
143
+ */
140
144
  siteName?: string;
145
+
146
+ /**
147
+ * URL of the API, defaults to API_URL env var
148
+ */
141
149
  apiUrl?: string;
150
+
151
+ /**
152
+ * Arbitrary data to put in runtime config
153
+ */
142
154
  runtimeConfig?: Extract<NuxtConfig, "runtimeConfig">;
155
+
156
+ /**
157
+ * DSN for Sentry, defaults to SENTRY_DSN env var
158
+ */
143
159
  sentryDsn?: string;
160
+
161
+ /**
162
+ * Environment name, especially for Sentry
163
+ */
144
164
  environment?: string;
165
+
166
+ /**
167
+ * Raw "app" setting, will be merged with defaults
168
+ */
145
169
  app?: Extract<NuxtConfig, "app">;
170
+
171
+ /**
172
+ * Raw "head" setting from the "app" setting, will be merged with defaults
173
+ */
146
174
  head?: Extract<Extract<NuxtConfig, "app">, "head">;
175
+
176
+ /**
177
+ * Additional list of modules you'd like to have
178
+ */
147
179
  moduleConfig?: Array<any>;
180
+
181
+ /**
182
+ * URL prefix of the backend (without initial /), defaults to back
183
+ */
148
184
  backAlias?: string;
185
+
186
+ /**
187
+ * URL prefix of the CMS admin (without initial /), defaults to cms
188
+ */
149
189
  cmsAlias?: string;
190
+
191
+ /**
192
+ * Additional rules for the proxy module
193
+ */
150
194
  proxyFilters?: Array<any>;
195
+
196
+ /**
197
+ * Set to false to disable the runtime template compilation (which makes
198
+ * the bundle lighter)
199
+ */
200
+ enableRuntimeTemplate?: boolean;
151
201
  }
152
202
 
153
203
  /**
@@ -207,6 +257,8 @@ export function defineModelWConfig(
207
257
  defaultValue: sentryDsn ? undefined : "",
208
258
  });
209
259
 
260
+ const enableRuntimeTemplate = config.enableRuntimeTemplate !== false;
261
+
210
262
  const generatedConfig: NuxtConfig = {
211
263
  app,
212
264
 
@@ -224,12 +276,6 @@ export function defineModelWConfig(
224
276
  {
225
277
  header: /x-reach-api:.+/,
226
278
  },
227
- {
228
- path: `/${backAlias}`,
229
- },
230
- {
231
- path: `/${cmsAlias}`,
232
- },
233
279
  {
234
280
  path: previewEditRegex,
235
281
  method: /^(?!POST$).*/,
@@ -240,6 +286,12 @@ export function defineModelWConfig(
240
286
  method: /^(?!POST$).*/,
241
287
  useProxy: false,
242
288
  },
289
+ {
290
+ path: `/${backAlias}`,
291
+ },
292
+ {
293
+ path: `/${cmsAlias}`,
294
+ },
243
295
  ...(config.proxyFilters || []),
244
296
  ],
245
297
  } as ProxyOptions,
@@ -255,6 +307,21 @@ export function defineModelWConfig(
255
307
  "@model-w/proxy",
256
308
  ...(config.moduleConfig || []),
257
309
  ],
310
+
311
+ ...(enableRuntimeTemplate
312
+ ? {
313
+ vite: {
314
+ resolve: {
315
+ alias: {
316
+ vue: resolve(
317
+ __dirname,
318
+ "node_modules/vue/dist/vue.esm-bundler.js"
319
+ ),
320
+ },
321
+ },
322
+ },
323
+ }
324
+ : {}),
258
325
  };
259
326
 
260
327
  return defineNuxtConfig(generatedConfig);
package/package.json CHANGED
@@ -1,15 +1,28 @@
1
1
  {
2
2
  "name": "@model-w/preset-nuxt3",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
+ "type": "module",
5
+ "description": "Preset of Nuxt3 for ModelW",
6
+ "license": "WTFPL",
4
7
  "repository": {
5
8
  "type": "git",
6
9
  "url": "git+https://github.com/ModelW/preset-nuxt3.git"
7
10
  },
11
+ "homepage": "https://github.com/ModelW/preset-nuxt3#readme",
8
12
  "bugs": {
9
13
  "url": "https://github.com/ModelW/preset-nuxt3/issues"
10
14
  },
11
- "description": "Preset of Nuxt3 for ModelW",
12
- "homepage": "https://github.com/ModelW/preset-nuxt3#readme",
15
+ "author": "Rémy Sanchez (@xowap)",
16
+ "contributors": [
17
+ "Laurent Treguier",
18
+ "Ivan Lorenzo"
19
+ ],
20
+ "keywords": [
21
+ "nuxt3",
22
+ "nuxt3-preset",
23
+ "model-w",
24
+ "modelw"
25
+ ],
13
26
  "main": "index.ts",
14
27
  "files": [
15
28
  "index.ts",
@@ -33,18 +46,6 @@
33
46
  "vite-svg-loader": "4.0.x",
34
47
  "vue": "3.2.x"
35
48
  },
36
- "keywords": [
37
- "Nuxt3",
38
- "modelw",
39
- "model-w",
40
- "Nuxt3-preset"
41
- ],
42
- "author": "Rémy Sanchez (@xowap)",
43
- "license": "WTFPL",
44
- "contributors": [
45
- "Laurent Treguier",
46
- "Ivan Lorenzo"
47
- ],
48
49
  "dependencies": {
49
50
  "defu": "^6.1.2"
50
51
  }