@model-w/preset-nuxt3 1.0.1 → 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.
- package/index.ts +73 -6
- package/package.json +1 -1
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);
|