vitrify 0.5.2 → 0.5.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/dist/bin/build.js CHANGED
@@ -13,7 +13,7 @@ export async function build(opts) {
13
13
  });
14
14
  config.build = {
15
15
  ...config.build,
16
- minify: false,
16
+ minify: !opts.debug,
17
17
  outDir: opts.outDir,
18
18
  emptyOutDir: !!opts.outDir
19
19
  };
package/dist/bin/dev.js CHANGED
@@ -25,7 +25,6 @@ ssr, framework = 'vue', host, appDir, publicDir, base }) {
25
25
  base
26
26
  });
27
27
  config.logLevel = logLevel;
28
- console.log(searchForWorkspaceRoot(appDir.pathname));
29
28
  config.server = {
30
29
  https: config.server?.https,
31
30
  hmr: {
@@ -1,4 +1,4 @@
1
- import { fastifyStatic } from '@fastify/static';
1
+ import fastifyStatic from '@fastify/static';
2
2
  const fastifyCsrPlugin = async (fastify, options, done) => {
3
3
  options.vitrifyDir =
4
4
  options.vitrifyDir || (await import('vitrify')).vitrifyDir;
@@ -1,4 +1,4 @@
1
- import { fastifyStatic } from '@fastify/static';
1
+ import fastifyStatic from '@fastify/static';
2
2
  import { readFileSync } from 'fs';
3
3
  import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js';
4
4
  const fastifySsrPlugin = async (fastify, options, done) => {
package/dist/index.js CHANGED
@@ -43,7 +43,9 @@ const manualChunks = (id) => {
43
43
  export const VIRTUAL_MODULES = [
44
44
  'virtual:vitrify-hooks',
45
45
  'virtual:global-css',
46
- 'virtual:static-imports'
46
+ 'virtual:static-imports',
47
+ 'vitrify.sass',
48
+ 'vitrify.css'
47
49
  ];
48
50
  async function bundleConfigFile(fileName, isESM = false) {
49
51
  const result = await build({
@@ -175,6 +177,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
175
177
  let staticImports;
176
178
  let sassVariables;
177
179
  let additionalData;
180
+ let globalSass;
178
181
  let serverModules = internalServerModules;
179
182
  if (vitrifyConfig.vitrify?.ssr?.serverModules)
180
183
  serverModules = [
@@ -215,17 +218,20 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
215
218
  globalCss = config.vitrify?.globalCss || [];
216
219
  staticImports = config.vitrify?.staticImports || {};
217
220
  sassVariables = config.vitrify?.sass?.variables || {};
221
+ globalSass = config.vitrify?.sass?.global || [];
218
222
  additionalData = config.vitrify?.sass?.additionalData || [];
219
223
  return {
220
224
  css: {
221
225
  preprocessorOptions: {
222
- sass: {
223
- additionalData: [
224
- ...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
225
- ...additionalData
226
- // config.css?.preprocessorOptions?.sass.additionalData
227
- ].join('\n')
228
- }
226
+ // sass: {
227
+ // additionalData: [
228
+ // ...Object.entries(sassVariables).map(
229
+ // ([key, value]) => `${key}: ${value}`
230
+ // )
231
+ // // ...additionalData
232
+ // // config.css?.preprocessorOptions?.sass.additionalData
233
+ // ].join('\n')
234
+ // }
229
235
  }
230
236
  }
231
237
  };
@@ -238,7 +244,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
238
244
  },
239
245
  resolveId(id) {
240
246
  if (VIRTUAL_MODULES.includes(id))
241
- return { id, moduleSideEffects: false };
247
+ return { id };
242
248
  return;
243
249
  },
244
250
  transform: (code, id) => {
@@ -281,6 +287,15 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
281
287
  .map(([key, value]) => `export { ${value.join(',')} } from '${key}';`)
282
288
  .join('\n')}`;
283
289
  }
290
+ else if (id === 'vitrify.sass') {
291
+ return [
292
+ ...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
293
+ ...globalSass.map((sass) => `@import '${sass}'`)
294
+ ].join('\n');
295
+ }
296
+ else if (id === 'vitrify.css') {
297
+ return `${globalCss.map((css) => `import '${css}'`).join('\n')}`;
298
+ }
284
299
  return null;
285
300
  }
286
301
  }
@@ -377,7 +392,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
377
392
  ],
378
393
  external,
379
394
  output: {
380
- minifyInternalExports: false,
395
+ minifyInternalExports: !debug,
381
396
  entryFileNames: '[name].mjs',
382
397
  chunkFileNames: '[name].mjs',
383
398
  format: 'es',
@@ -433,7 +448,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
433
448
  // ],
434
449
  external,
435
450
  output: {
436
- minifyInternalExports: false,
451
+ minifyInternalExports: !debug,
437
452
  entryFileNames: '[name].mjs',
438
453
  chunkFileNames: '[name].mjs',
439
454
  format: 'es',
@@ -93,7 +93,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
93
93
  onRendered: [injectSsrContext]
94
94
  },
95
95
  sass: {
96
- additionalData: [`@import 'quasar/src/css/index.sass'`]
96
+ global: ['quasar/src/css/index.sass']
97
+ // additionalData: [`@import 'quasar/src/css/index.sass'`]
97
98
  }
98
99
  }
99
100
  };
@@ -149,16 +150,17 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
149
150
  find: 'quasar/src',
150
151
  replacement: new URL('src/', urls?.packages?.quasar).pathname
151
152
  },
152
- {
153
- find: new RegExp('^quasar$'),
154
- replacement: new URL('src/index.all.js', urls?.packages?.quasar)
155
- .pathname
156
- },
153
+ // {
154
+ // find: new RegExp('^quasar$'),
155
+ // replacement: new URL('src/index.all.js', urls?.packages?.quasar)
156
+ // .pathname
157
+ // },
157
158
  {
158
159
  find: `@quasar/extras`,
159
160
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
160
161
  .pathname
161
162
  }
163
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
162
164
  ]
163
165
  },
164
166
  define: {
@@ -180,11 +182,11 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
180
182
  },
181
183
  {
182
184
  name: 'quasar-virtual-modules',
183
- enforce: 'post',
185
+ enforce: 'pre',
184
186
  config: async (config, env) => ({
185
187
  resolve: {
186
188
  alias: [
187
- { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
189
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
188
190
  ]
189
191
  }
190
192
  }),
@@ -192,8 +194,8 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
192
194
  switch (id) {
193
195
  case 'virtual:quasar-plugins':
194
196
  return 'virtual:quasar-plugins';
195
- case 'virtual:quasar':
196
- return { id: 'virtual:quasar', moduleSideEffects: false };
197
+ case 'quasar':
198
+ return { id: 'quasar', moduleSideEffects: false };
197
199
  default:
198
200
  return;
199
201
  }
@@ -202,7 +204,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
202
204
  if (id === 'virtual:quasar-plugins') {
203
205
  return `export { ${plugins.join(',')} } from 'quasar'`;
204
206
  }
205
- else if (id === 'virtual:quasar') {
207
+ else if (id === 'quasar') {
206
208
  return `export * from 'quasar/src/plugins.js';
207
209
  export * from 'quasar/src/components.js';
208
210
  export * from 'quasar/src/composables.js';
@@ -50,6 +50,7 @@ export interface VitrifyConfig extends UserConfig {
50
50
  sass?: {
51
51
  variables?: Record<string, string>;
52
52
  additionalData?: string[];
53
+ global?: string[];
53
54
  };
54
55
  /**
55
56
  * Product name of the application. Will be used for the HTML title tag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -93,7 +93,6 @@
93
93
  "peerDependencies": {
94
94
  "@fastify/static": "^6.4.0",
95
95
  "fastify": "^4.0.0",
96
- "fastify-plugin": "^3.0.1",
97
96
  "import-meta-resolve": "^2.0.3",
98
97
  "quasar": "^2.7.1",
99
98
  "vue": "^3.2.37",
@@ -22,7 +22,7 @@ export async function build(opts: {
22
22
 
23
23
  config.build = {
24
24
  ...config.build,
25
- minify: false,
25
+ minify: !opts.debug,
26
26
  outDir: opts.outDir,
27
27
  emptyOutDir: !!opts.outDir
28
28
  }
@@ -52,7 +52,6 @@ export async function createVitrifyDevServer({
52
52
 
53
53
  config.logLevel = logLevel
54
54
 
55
- console.log(searchForWorkspaceRoot(appDir.pathname))
56
55
  config.server = {
57
56
  https: config.server?.https,
58
57
  hmr: {
@@ -3,7 +3,7 @@ import type {
3
3
  FastifyRequest,
4
4
  FastifyReply
5
5
  } from 'fastify'
6
- import { fastifyStatic } from '@fastify/static'
6
+ import fastifyStatic from '@fastify/static'
7
7
  import type { OnRenderedHook } from '../../vitrify-config.js'
8
8
  import type { ViteDevServer } from 'vite'
9
9
 
@@ -3,7 +3,7 @@ import type {
3
3
  FastifyRequest,
4
4
  FastifyReply
5
5
  } from 'fastify'
6
- import { fastifyStatic } from '@fastify/static'
6
+ import fastifyStatic from '@fastify/static'
7
7
  import { readFileSync } from 'fs'
8
8
  import type { OnRenderedHook } from '../../vitrify-config.js'
9
9
  import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js'
package/src/node/index.ts CHANGED
@@ -61,7 +61,9 @@ const manualChunks: ManualChunksOption = (id: string) => {
61
61
  export const VIRTUAL_MODULES = [
62
62
  'virtual:vitrify-hooks',
63
63
  'virtual:global-css',
64
- 'virtual:static-imports'
64
+ 'virtual:static-imports',
65
+ 'vitrify.sass',
66
+ 'vitrify.css'
65
67
  ]
66
68
 
67
69
  async function bundleConfigFile(
@@ -247,6 +249,7 @@ export const baseConfig = async ({
247
249
  let staticImports: StaticImports
248
250
  let sassVariables: Record<string, string>
249
251
  let additionalData: string[]
252
+ let globalSass: string[]
250
253
  let serverModules: string[] = internalServerModules
251
254
 
252
255
  if (vitrifyConfig.vitrify?.ssr?.serverModules)
@@ -289,20 +292,21 @@ export const baseConfig = async ({
289
292
  globalCss = config.vitrify?.globalCss || []
290
293
  staticImports = config.vitrify?.staticImports || {}
291
294
  sassVariables = config.vitrify?.sass?.variables || {}
295
+ globalSass = config.vitrify?.sass?.global || []
292
296
  additionalData = config.vitrify?.sass?.additionalData || []
293
297
 
294
298
  return {
295
299
  css: {
296
300
  preprocessorOptions: {
297
- sass: {
298
- additionalData: [
299
- ...Object.entries(sassVariables).map(
300
- ([key, value]) => `${key}: ${value}`
301
- ),
302
- ...additionalData
303
- // config.css?.preprocessorOptions?.sass.additionalData
304
- ].join('\n')
305
- }
301
+ // sass: {
302
+ // additionalData: [
303
+ // ...Object.entries(sassVariables).map(
304
+ // ([key, value]) => `${key}: ${value}`
305
+ // )
306
+ // // ...additionalData
307
+ // // config.css?.preprocessorOptions?.sass.additionalData
308
+ // ].join('\n')
309
+ // }
306
310
  }
307
311
  }
308
312
  }
@@ -314,8 +318,7 @@ export const baseConfig = async ({
314
318
  }
315
319
  },
316
320
  resolveId(id) {
317
- if (VIRTUAL_MODULES.includes(id))
318
- return { id, moduleSideEffects: false }
321
+ if (VIRTUAL_MODULES.includes(id)) return { id }
319
322
  return
320
323
  },
321
324
  transform: (code, id) => {
@@ -363,6 +366,15 @@ export const baseConfig = async ({
363
366
  ([key, value]) => `export { ${value.join(',')} } from '${key}';`
364
367
  )
365
368
  .join('\n')}`
369
+ } else if (id === 'vitrify.sass') {
370
+ return [
371
+ ...Object.entries(sassVariables).map(
372
+ ([key, value]) => `${key}: ${value}`
373
+ ),
374
+ ...globalSass.map((sass) => `@import '${sass}'`)
375
+ ].join('\n')
376
+ } else if (id === 'vitrify.css') {
377
+ return `${globalCss.map((css) => `import '${css}'`).join('\n')}`
366
378
  }
367
379
  return null
368
380
  }
@@ -465,7 +477,7 @@ export const baseConfig = async ({
465
477
  ],
466
478
  external,
467
479
  output: {
468
- minifyInternalExports: false,
480
+ minifyInternalExports: !debug,
469
481
  entryFileNames: '[name].mjs',
470
482
  chunkFileNames: '[name].mjs',
471
483
  format: 'es',
@@ -519,7 +531,7 @@ export const baseConfig = async ({
519
531
  // ],
520
532
  external,
521
533
  output: {
522
- minifyInternalExports: false,
534
+ minifyInternalExports: !debug,
523
535
  entryFileNames: '[name].mjs',
524
536
  chunkFileNames: '[name].mjs',
525
537
  format: 'es',
@@ -168,7 +168,8 @@ export const QuasarPlugin: VitrifyPlugin = async ({
168
168
  onRendered: [injectSsrContext]
169
169
  },
170
170
  sass: {
171
- additionalData: [`@import 'quasar/src/css/index.sass'`]
171
+ global: ['quasar/src/css/index.sass']
172
+ // additionalData: [`@import 'quasar/src/css/index.sass'`]
172
173
  }
173
174
  }
174
175
  }
@@ -232,7 +233,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
232
233
  urls?.packages?.quasar
233
234
  ).pathname
234
235
  },
235
-
236
236
  {
237
237
  find: 'quasar/directives',
238
238
  replacement: new URL(
@@ -244,16 +244,17 @@ export const QuasarPlugin: VitrifyPlugin = async ({
244
244
  find: 'quasar/src',
245
245
  replacement: new URL('src/', urls?.packages?.quasar).pathname
246
246
  },
247
- {
248
- find: new RegExp('^quasar$'),
249
- replacement: new URL('src/index.all.js', urls?.packages?.quasar)
250
- .pathname
251
- },
247
+ // {
248
+ // find: new RegExp('^quasar$'),
249
+ // replacement: new URL('src/index.all.js', urls?.packages?.quasar)
250
+ // .pathname
251
+ // },
252
252
  {
253
253
  find: `@quasar/extras`,
254
254
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
255
255
  .pathname
256
256
  }
257
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
257
258
  ]
258
259
  },
259
260
  define: {
@@ -275,11 +276,11 @@ export const QuasarPlugin: VitrifyPlugin = async ({
275
276
  },
276
277
  {
277
278
  name: 'quasar-virtual-modules',
278
- enforce: 'post',
279
+ enforce: 'pre',
279
280
  config: async (config, env) => ({
280
281
  resolve: {
281
282
  alias: [
282
- { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
283
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
283
284
  ]
284
285
  }
285
286
  }),
@@ -287,8 +288,8 @@ export const QuasarPlugin: VitrifyPlugin = async ({
287
288
  switch (id) {
288
289
  case 'virtual:quasar-plugins':
289
290
  return 'virtual:quasar-plugins'
290
- case 'virtual:quasar':
291
- return { id: 'virtual:quasar', moduleSideEffects: false }
291
+ case 'quasar':
292
+ return { id: 'quasar', moduleSideEffects: false }
292
293
  default:
293
294
  return
294
295
  }
@@ -296,7 +297,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
296
297
  load(id) {
297
298
  if (id === 'virtual:quasar-plugins') {
298
299
  return `export { ${plugins.join(',')} } from 'quasar'`
299
- } else if (id === 'virtual:quasar') {
300
+ } else if (id === 'quasar') {
300
301
  return `export * from 'quasar/src/plugins.js';
301
302
  export * from 'quasar/src/components.js';
302
303
  export * from 'quasar/src/composables.js';
@@ -71,6 +71,7 @@ export interface VitrifyConfig extends UserConfig {
71
71
  sass?: {
72
72
  variables?: Record<string, string>
73
73
  additionalData?: string[]
74
+ global?: string[]
74
75
  }
75
76
  /**
76
77
  * Product name of the application. Will be used for the HTML title tag
@@ -1,3 +1,5 @@
1
+ // import 'vitrify.css'
2
+ import 'vitrify.sass'
1
3
  import App from 'src/App.vue'
2
4
  import createRouter from 'src/router'
3
5
  import {