@model-w/preset-nuxt3 1.0.1 → 1.0.3
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 +71 -6
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -137,17 +137,66 @@ class EnvManager {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export interface ModelWConfig {
|
|
140
|
+
/**
|
|
141
|
+
* Site name for display purposes
|
|
142
|
+
*/
|
|
140
143
|
siteName?: string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* URL of the API, defaults to API_URL env var
|
|
147
|
+
*/
|
|
141
148
|
apiUrl?: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Arbitrary data to put in runtime config
|
|
152
|
+
*/
|
|
142
153
|
runtimeConfig?: Extract<NuxtConfig, "runtimeConfig">;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* DSN for Sentry, defaults to SENTRY_DSN env var
|
|
157
|
+
*/
|
|
143
158
|
sentryDsn?: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Environment name, especially for Sentry
|
|
162
|
+
*/
|
|
144
163
|
environment?: string;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Raw "app" setting, will be merged with defaults
|
|
167
|
+
*/
|
|
145
168
|
app?: Extract<NuxtConfig, "app">;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Raw "head" setting from the "app" setting, will be merged with defaults
|
|
172
|
+
*/
|
|
146
173
|
head?: Extract<Extract<NuxtConfig, "app">, "head">;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Additional list of modules you'd like to have
|
|
177
|
+
*/
|
|
147
178
|
moduleConfig?: Array<any>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* URL prefix of the backend (without initial /), defaults to back
|
|
182
|
+
*/
|
|
148
183
|
backAlias?: string;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* URL prefix of the CMS admin (without initial /), defaults to cms
|
|
187
|
+
*/
|
|
149
188
|
cmsAlias?: string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Additional rules for the proxy module
|
|
192
|
+
*/
|
|
150
193
|
proxyFilters?: Array<any>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Set to false to disable the runtime template compilation (which makes
|
|
197
|
+
* the bundle lighter)
|
|
198
|
+
*/
|
|
199
|
+
enableRuntimeTemplate?: boolean;
|
|
151
200
|
}
|
|
152
201
|
|
|
153
202
|
/**
|
|
@@ -207,6 +256,8 @@ export function defineModelWConfig(
|
|
|
207
256
|
defaultValue: sentryDsn ? undefined : "",
|
|
208
257
|
});
|
|
209
258
|
|
|
259
|
+
const enableRuntimeTemplate = config.enableRuntimeTemplate !== false;
|
|
260
|
+
|
|
210
261
|
const generatedConfig: NuxtConfig = {
|
|
211
262
|
app,
|
|
212
263
|
|
|
@@ -224,12 +275,6 @@ export function defineModelWConfig(
|
|
|
224
275
|
{
|
|
225
276
|
header: /x-reach-api:.+/,
|
|
226
277
|
},
|
|
227
|
-
{
|
|
228
|
-
path: `/${backAlias}`,
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
path: `/${cmsAlias}`,
|
|
232
|
-
},
|
|
233
278
|
{
|
|
234
279
|
path: previewEditRegex,
|
|
235
280
|
method: /^(?!POST$).*/,
|
|
@@ -240,6 +285,12 @@ export function defineModelWConfig(
|
|
|
240
285
|
method: /^(?!POST$).*/,
|
|
241
286
|
useProxy: false,
|
|
242
287
|
},
|
|
288
|
+
{
|
|
289
|
+
path: `/${backAlias}`,
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
path: `/${cmsAlias}`,
|
|
293
|
+
},
|
|
243
294
|
...(config.proxyFilters || []),
|
|
244
295
|
],
|
|
245
296
|
} as ProxyOptions,
|
|
@@ -255,6 +306,20 @@ export function defineModelWConfig(
|
|
|
255
306
|
"@model-w/proxy",
|
|
256
307
|
...(config.moduleConfig || []),
|
|
257
308
|
],
|
|
309
|
+
|
|
310
|
+
...(enableRuntimeTemplate
|
|
311
|
+
? {
|
|
312
|
+
vite: {
|
|
313
|
+
resolve: {
|
|
314
|
+
alias: {
|
|
315
|
+
vue: require.resolve(
|
|
316
|
+
"vue/dist/vue.esm-bundler.js"
|
|
317
|
+
),
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
}
|
|
322
|
+
: {}),
|
|
258
323
|
};
|
|
259
324
|
|
|
260
325
|
return defineNuxtConfig(generatedConfig);
|