vitrify 0.7.0 → 0.8.0
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/dev.js +0 -1
- package/dist/frameworks/vue/fastify-ssr-plugin.js +3 -3
- package/dist/frameworks/vue/server.js +5 -5
- package/dist/index.js +7 -5
- package/dist/plugins/quasar.js +20 -111
- package/dist/types/bin/dev.d.ts +1 -1
- package/dist/types/frameworks/vue/server.d.ts +2 -2
- package/package.json +8 -7
- package/src/node/bin/dev.ts +0 -1
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +3 -3
- package/src/node/frameworks/vue/server.ts +6 -6
- package/src/node/index.ts +7 -6
- package/src/node/plugins/quasar.ts +21 -118
- package/src/vite/vue/ssr/app.ts +1 -0
package/dist/bin/dev.js
CHANGED
|
@@ -84,7 +84,6 @@ ssr, framework = 'vue', host, appDir, publicDir }) {
|
|
|
84
84
|
? new URL('src/vite/fastify/entry.ts', cliDir).pathname
|
|
85
85
|
: new URL(`src/vite/${framework}/ssr/app.ts`, cliDir).pathname;
|
|
86
86
|
({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl));
|
|
87
|
-
console.log(vitrifyConfig);
|
|
88
87
|
const app = fastify({
|
|
89
88
|
logger: false,
|
|
90
89
|
https: vite.config.server.https,
|
|
@@ -2,9 +2,6 @@ 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) => {
|
|
5
|
-
options.vitrifyDir =
|
|
6
|
-
options.vitrifyDir || (await import('vitrify')).vitrifyDir;
|
|
7
|
-
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir);
|
|
8
5
|
options.baseUrl = options.baseUrl || '/';
|
|
9
6
|
options.mode = options.mode || process.env.MODE || import.meta.env.MODE;
|
|
10
7
|
options.appDir = options.appDir || new URL('../../..', import.meta.url);
|
|
@@ -12,6 +9,9 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
12
9
|
options.baseUrl.charAt(0) !== '/')
|
|
13
10
|
throw new Error('baseUrl should start and end with a /');
|
|
14
11
|
if (options.mode === 'development') {
|
|
12
|
+
options.vitrifyDir =
|
|
13
|
+
options.vitrifyDir || (await import('vitrify')).vitrifyDir;
|
|
14
|
+
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir);
|
|
15
15
|
// if (!options.vitrifyDir)
|
|
16
16
|
// throw new Error('Option vitrifyDir cannot be undefined')
|
|
17
17
|
// if (!options.vite) throw new Error('Option vite cannot be undefined')
|
|
@@ -10,10 +10,10 @@ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered,
|
|
|
10
10
|
onRendered,
|
|
11
11
|
mode
|
|
12
12
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
if (onSetup?.length) {
|
|
14
|
+
for (const setup of onSetup) {
|
|
15
|
+
setup(app);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
18
|
return app;
|
|
19
19
|
};
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import builtinModules from 'builtin-modules';
|
|
|
10
10
|
// import { resolve } from 'import-meta-resolve'
|
|
11
11
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
12
12
|
import { resolve } from './app-urls.js';
|
|
13
|
+
import envPlugin from '@vitrify/plugin-env';
|
|
13
14
|
const internalServerModules = [
|
|
14
15
|
'util',
|
|
15
16
|
'vitrify',
|
|
@@ -183,7 +184,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
183
184
|
let onRenderedHooks;
|
|
184
185
|
let onMountedHooks;
|
|
185
186
|
let onSetupFiles;
|
|
186
|
-
let globalCss;
|
|
187
|
+
let globalCss = [];
|
|
187
188
|
let staticImports;
|
|
188
189
|
let sassVariables;
|
|
189
190
|
let additionalData;
|
|
@@ -196,11 +197,12 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
196
197
|
];
|
|
197
198
|
const plugins = [
|
|
198
199
|
vuePlugin(),
|
|
200
|
+
envPlugin(),
|
|
199
201
|
...frameworkPlugins,
|
|
200
202
|
{
|
|
201
203
|
name: 'vitrify-setup',
|
|
202
204
|
enforce: 'post',
|
|
203
|
-
config:
|
|
205
|
+
config: (config, env) => {
|
|
204
206
|
onBootHooks = config.vitrify?.hooks?.onBoot || [];
|
|
205
207
|
onRenderedHooks = config.vitrify?.hooks?.onRendered || [];
|
|
206
208
|
onMountedHooks = config.vitrify?.hooks?.onMounted || [];
|
|
@@ -210,7 +212,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
210
212
|
sassVariables = config.vitrify?.sass?.variables || {};
|
|
211
213
|
globalSass = config.vitrify?.sass?.global || [];
|
|
212
214
|
additionalData = config.vitrify?.sass?.additionalData || [];
|
|
213
|
-
return
|
|
215
|
+
return;
|
|
214
216
|
},
|
|
215
217
|
configureServer(server) {
|
|
216
218
|
server.middlewares.use('/', (req, res, next) => {
|
|
@@ -221,8 +223,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
221
223
|
},
|
|
222
224
|
configResolved: (config) => {
|
|
223
225
|
if (process.env.DEBUG) {
|
|
224
|
-
console.log(config
|
|
225
|
-
console.log(config.optimizeDeps);
|
|
226
|
+
console.log(config);
|
|
226
227
|
}
|
|
227
228
|
},
|
|
228
229
|
resolveId(id) {
|
|
@@ -327,6 +328,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
327
328
|
config: (config, env) => {
|
|
328
329
|
if (config.vitrify?.productName)
|
|
329
330
|
productName = config.vitrify?.productName;
|
|
331
|
+
return;
|
|
330
332
|
},
|
|
331
333
|
transformIndexHtml: {
|
|
332
334
|
enforce: 'post',
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { resolvePackageData } from 'vite';
|
|
2
2
|
import Components from 'unplugin-vue-components/vite';
|
|
3
|
-
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
4
|
-
// import { QuasarResolver } from '../resolver.js';
|
|
5
3
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers';
|
|
6
4
|
export const injectSsrContext = (html, ssrContext) => html
|
|
7
5
|
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
@@ -40,12 +38,12 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
40
38
|
name: 'vite-plugin-quasar-transform',
|
|
41
39
|
enforce: 'pre',
|
|
42
40
|
transform: (code, id, options) => {
|
|
43
|
-
const { ssr
|
|
41
|
+
const { ssr } = options || {};
|
|
44
42
|
code = code
|
|
45
43
|
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
46
|
-
.replaceAll('__QUASAR_SSR_SERVER__', ssr
|
|
47
|
-
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '
|
|
48
|
-
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '
|
|
44
|
+
.replaceAll('__QUASAR_SSR_SERVER__', ssr ? '(import.meta.env.SSR === true)' : 'false')
|
|
45
|
+
.replaceAll('__QUASAR_SSR_CLIENT__', ssr ? '(import.meta.env.SSR === false)' : 'false')
|
|
46
|
+
.replaceAll('__QUASAR_SSR_PWA__', ssr && pwa ? '(import.meta.env.SSR === false)' : 'false');
|
|
49
47
|
return code;
|
|
50
48
|
}
|
|
51
49
|
},
|
|
@@ -86,45 +84,10 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
86
84
|
}, ssrContext);
|
|
87
85
|
}
|
|
88
86
|
];
|
|
89
|
-
return {
|
|
90
|
-
vitrify: {
|
|
91
|
-
urls,
|
|
92
|
-
globalCss,
|
|
93
|
-
staticImports: {
|
|
94
|
-
quasar: ['Quasar']
|
|
95
|
-
},
|
|
96
|
-
hooks: {
|
|
97
|
-
onBoot: onBootHooks,
|
|
98
|
-
onMounted: onMountedHooks,
|
|
99
|
-
onRendered: [injectSsrContext]
|
|
100
|
-
},
|
|
101
|
-
sass: {
|
|
102
|
-
global: ['quasar/src/css/index.sass']
|
|
103
|
-
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'vite-plugin-quasar',
|
|
111
|
-
enforce: 'post',
|
|
112
|
-
config: async (config, env) => {
|
|
113
|
-
const { quasar, vitrify: { urls } = {} } = config;
|
|
114
87
|
if (quasar)
|
|
115
88
|
quasarConf = quasar;
|
|
116
89
|
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
117
90
|
quasarConf.framework.lang = config.vitrify.lang;
|
|
118
|
-
// const quasarPkgJsonPath = new URL(
|
|
119
|
-
// 'package.json',
|
|
120
|
-
// urls?.packages?.quasar
|
|
121
|
-
// ).pathname
|
|
122
|
-
// const { version } = JSON.parse(
|
|
123
|
-
// readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' })
|
|
124
|
-
// )
|
|
125
|
-
// const { version } = await import('quasar/package.json', {
|
|
126
|
-
// assert: { type: 'json' }
|
|
127
|
-
// })
|
|
128
91
|
/**
|
|
129
92
|
* Importing package.json is problematic
|
|
130
93
|
*/
|
|
@@ -141,75 +104,28 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
141
104
|
plugins = quasarConf?.framework.plugins;
|
|
142
105
|
}
|
|
143
106
|
return {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
107
|
+
vitrify: {
|
|
108
|
+
urls,
|
|
109
|
+
globalCss,
|
|
110
|
+
staticImports: {
|
|
111
|
+
quasar: ['Quasar']
|
|
112
|
+
},
|
|
113
|
+
hooks: {
|
|
114
|
+
onBoot: onBootHooks,
|
|
115
|
+
onMounted: onMountedHooks,
|
|
116
|
+
onRendered: [injectSsrContext]
|
|
117
|
+
},
|
|
118
|
+
sass: {
|
|
119
|
+
global: ['quasar/src/css/index.sass']
|
|
120
|
+
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
151
123
|
resolve: {
|
|
152
|
-
// dedupe: ['quasar', '@quasar/extras'],
|
|
153
124
|
alias: [
|
|
154
|
-
// {
|
|
155
|
-
// find: 'quasar/wrappers',
|
|
156
|
-
// replacement: new URL('quasar-wrappers.ts', urls?.cli).pathname
|
|
157
|
-
// },
|
|
158
|
-
// {
|
|
159
|
-
// find: 'quasar/vue-plugin',
|
|
160
|
-
// replacement: new URL(
|
|
161
|
-
// 'src/vue-plugin.js',
|
|
162
|
-
// urls?.packages?.quasar
|
|
163
|
-
// ).pathname
|
|
164
|
-
// },
|
|
165
|
-
// {
|
|
166
|
-
// find: 'quasar/plugins',
|
|
167
|
-
// replacement: new URL('src/plugins.js', urls?.packages?.quasar)
|
|
168
|
-
// .pathname
|
|
169
|
-
// },
|
|
170
|
-
// {
|
|
171
|
-
// find: 'quasar/components',
|
|
172
|
-
// replacement: new URL(
|
|
173
|
-
// 'src/components.js',
|
|
174
|
-
// urls?.packages?.quasar
|
|
175
|
-
// ).pathname
|
|
176
|
-
// },
|
|
177
|
-
// {
|
|
178
|
-
// find: 'quasar/composables',
|
|
179
|
-
// replacement: new URL(
|
|
180
|
-
// 'src/composables.js',
|
|
181
|
-
// urls?.packages?.quasar
|
|
182
|
-
// ).pathname
|
|
183
|
-
// },
|
|
184
|
-
// {
|
|
185
|
-
// find: 'quasar/directives',
|
|
186
|
-
// replacement: new URL(
|
|
187
|
-
// 'src/directives.js',
|
|
188
|
-
// urls?.packages?.quasar
|
|
189
|
-
// ).pathname
|
|
190
|
-
// },
|
|
191
125
|
{
|
|
192
126
|
find: 'quasar/src/',
|
|
193
127
|
replacement: new URL('./src/', config.vitrify.urls.packages.quasar).pathname
|
|
194
128
|
}
|
|
195
|
-
// {
|
|
196
|
-
// find: 'quasar',
|
|
197
|
-
// replacement: new URL(
|
|
198
|
-
// 'node_modules/quasar',
|
|
199
|
-
// config.vitrify?.urls?.app
|
|
200
|
-
// )
|
|
201
|
-
// }
|
|
202
|
-
// {
|
|
203
|
-
// find: new RegExp('^quasar$'),
|
|
204
|
-
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
205
|
-
// .pathname
|
|
206
|
-
// }
|
|
207
|
-
// {
|
|
208
|
-
// find: `@quasar/extras`,
|
|
209
|
-
// replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
210
|
-
// .pathname
|
|
211
|
-
// }
|
|
212
|
-
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
213
129
|
]
|
|
214
130
|
},
|
|
215
131
|
optimizeDeps: {
|
|
@@ -218,13 +134,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
218
134
|
define: {
|
|
219
135
|
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
220
136
|
__QUASAR_VERSION__: `'${version}'`
|
|
221
|
-
// __QUASAR_SSR__: !!ssr,
|
|
222
|
-
// // __QUASAR_SSR_SERVER__: ssr === 'server',
|
|
223
|
-
// __QUASAR_SSR_SERVER__: `import.meta.env.SSR`,
|
|
224
|
-
// // __QUASAR_SSR_CLIENT__: ssr === 'client',
|
|
225
|
-
// __QUASAR_SSR_CLIENT__: `!import.meta.env.SSR`,
|
|
226
|
-
// // __QUASAR_SSR_PWA__: ssr === 'client' && pwa
|
|
227
|
-
// __QUASAR_SSR_PWA__: pwa ? `!import.meta.env.SSR` : false
|
|
228
137
|
},
|
|
229
138
|
ssr: {
|
|
230
139
|
noExternal: ['quasar']
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
21
21
|
publicDir?: URL;
|
|
22
22
|
}): Promise<{
|
|
23
23
|
server: Server;
|
|
24
|
-
config: Readonly<Omit<import("vite").UserConfig, "
|
|
24
|
+
config: Readonly<Omit<import("vite").UserConfig, "plugins" | "assetsInclude" | "optimizeDeps" | "worker"> & {
|
|
25
25
|
configFile: string | undefined;
|
|
26
26
|
configFileDependencies: string[];
|
|
27
27
|
inlineConfig: InlineConfig;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { FastifyInstance } from 'fastify';
|
|
3
|
-
import type { OnRenderedHook
|
|
3
|
+
import type { OnRenderedHook } from '../../vitrify-config.js';
|
|
4
4
|
import type { FastifyCsrPlugin } from './fastify-csr-plugin.js';
|
|
5
5
|
import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
|
|
6
6
|
export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, vitrifyDir, mode }: {
|
|
7
|
-
onSetup:
|
|
7
|
+
onSetup: ((fastify: FastifyInstance) => void)[];
|
|
8
8
|
appDir: URL;
|
|
9
9
|
baseUrl?: string | undefined;
|
|
10
10
|
fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Pre-configured Vite CLI for your framework",
|
|
@@ -60,12 +60,13 @@
|
|
|
60
60
|
"@fastify/static": "^6.5.0",
|
|
61
61
|
"@quasar/extras": "^1.15.1",
|
|
62
62
|
"@vitejs/plugin-vue": "^3.0.1",
|
|
63
|
+
"@vitrify/plugin-env": "^0.1.0",
|
|
63
64
|
"builtin-modules": "^3.3.0",
|
|
64
65
|
"cac": "^6.7.12",
|
|
65
66
|
"chalk": "^5.0.1",
|
|
66
67
|
"critters": "^0.0.16",
|
|
67
68
|
"cross-env": "^7.0.3",
|
|
68
|
-
"esbuild": "^0.14.
|
|
69
|
+
"esbuild": "^0.14.53",
|
|
69
70
|
"fastify": "^4.3.0",
|
|
70
71
|
"glob": "^8.0.3",
|
|
71
72
|
"happy-dom": "^6.0.4",
|
|
@@ -73,11 +74,11 @@
|
|
|
73
74
|
"merge-deep": "^3.0.3",
|
|
74
75
|
"readline": "^1.3.0",
|
|
75
76
|
"rollup-plugin-visualizer": "^5.7.1",
|
|
76
|
-
"sass": "1.54.
|
|
77
|
+
"sass": "1.54.2",
|
|
77
78
|
"ts-node": "^10.9.1",
|
|
78
|
-
"unplugin-vue-components": "^0.
|
|
79
|
+
"unplugin-vue-components": "^0.22.0",
|
|
79
80
|
"vite": "^3.0.4",
|
|
80
|
-
"vitest": "^0.20.
|
|
81
|
+
"vitest": "^0.20.3"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@types/connect": "^3.4.35",
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
"@types/node": "^18.6.3",
|
|
87
88
|
"@types/ws": "^8.5.3",
|
|
88
89
|
"@vue/runtime-core": "^3.2.37",
|
|
89
|
-
"quasar": "^2.7.
|
|
90
|
+
"quasar": "^2.7.7",
|
|
90
91
|
"rollup": "^2.77.2",
|
|
91
92
|
"typescript": "^4.7.4",
|
|
92
93
|
"vue": "^3.2.37",
|
|
@@ -95,7 +96,7 @@
|
|
|
95
96
|
"peerDependencies": {
|
|
96
97
|
"@fastify/static": "^6.5.0",
|
|
97
98
|
"fastify": "^4.3.0",
|
|
98
|
-
"quasar": "^2.7.
|
|
99
|
+
"quasar": "^2.7.7",
|
|
99
100
|
"vue": "^3.2.37",
|
|
100
101
|
"vue-router": "^4.1.3"
|
|
101
102
|
},
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -138,7 +138,6 @@ export async function createServer({
|
|
|
138
138
|
: new URL(`src/vite/${framework}/ssr/app.ts`, cliDir).pathname
|
|
139
139
|
|
|
140
140
|
;({ setup, onRendered, vitrifyConfig } = await vite.ssrLoadModule(entryUrl))
|
|
141
|
-
console.log(vitrifyConfig)
|
|
142
141
|
const app = fastify({
|
|
143
142
|
logger: false,
|
|
144
143
|
https: vite.config.server.https,
|
|
@@ -30,9 +30,6 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
30
30
|
options,
|
|
31
31
|
done
|
|
32
32
|
) => {
|
|
33
|
-
options.vitrifyDir =
|
|
34
|
-
options.vitrifyDir || (await import('vitrify')).vitrifyDir
|
|
35
|
-
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir)
|
|
36
33
|
options.baseUrl = options.baseUrl || '/'
|
|
37
34
|
options.mode = options.mode || process.env.MODE || import.meta.env.MODE
|
|
38
35
|
options.appDir = options.appDir || new URL('../../..', import.meta.url)
|
|
@@ -43,6 +40,9 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
43
40
|
)
|
|
44
41
|
throw new Error('baseUrl should start and end with a /')
|
|
45
42
|
if (options.mode === 'development') {
|
|
43
|
+
options.vitrifyDir =
|
|
44
|
+
options.vitrifyDir || (await import('vitrify')).vitrifyDir
|
|
45
|
+
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir)
|
|
46
46
|
// if (!options.vitrifyDir)
|
|
47
47
|
// throw new Error('Option vitrifyDir cannot be undefined')
|
|
48
48
|
// if (!options.vite) throw new Error('Option vite cannot be undefined')
|
|
@@ -15,7 +15,7 @@ export const createApp = ({
|
|
|
15
15
|
vitrifyDir,
|
|
16
16
|
mode
|
|
17
17
|
}: {
|
|
18
|
-
onSetup:
|
|
18
|
+
onSetup: ((fastify: FastifyInstance) => void)[]
|
|
19
19
|
appDir: URL
|
|
20
20
|
baseUrl?: string
|
|
21
21
|
fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin
|
|
@@ -35,11 +35,11 @@ export const createApp = ({
|
|
|
35
35
|
mode
|
|
36
36
|
})
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
if (onSetup?.length) {
|
|
39
|
+
for (const setup of onSetup) {
|
|
40
|
+
setup(app)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
return app
|
|
45
45
|
}
|
package/src/node/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { VitrifyContext } from './bin/run.js'
|
|
|
23
23
|
import type { VitrifyPlugin } from './plugins/index.js'
|
|
24
24
|
import { resolve } from './app-urls.js'
|
|
25
25
|
import type { ManualChunksOption, RollupOptions } from 'rollup'
|
|
26
|
+
import envPlugin from '@vitrify/plugin-env'
|
|
26
27
|
|
|
27
28
|
const internalServerModules = [
|
|
28
29
|
'util',
|
|
@@ -254,7 +255,7 @@ export const baseConfig = async ({
|
|
|
254
255
|
let onRenderedHooks: OnRenderedHook[]
|
|
255
256
|
let onMountedHooks: OnMountedHook[]
|
|
256
257
|
let onSetupFiles: OnSetupFile[]
|
|
257
|
-
let globalCss: string[]
|
|
258
|
+
let globalCss: string[] = []
|
|
258
259
|
let staticImports: StaticImports
|
|
259
260
|
let sassVariables: Record<string, string>
|
|
260
261
|
let additionalData: string[]
|
|
@@ -269,11 +270,12 @@ export const baseConfig = async ({
|
|
|
269
270
|
|
|
270
271
|
const plugins: UserConfig['plugins'] = [
|
|
271
272
|
vuePlugin(),
|
|
273
|
+
envPlugin(),
|
|
272
274
|
...frameworkPlugins,
|
|
273
275
|
{
|
|
274
276
|
name: 'vitrify-setup',
|
|
275
277
|
enforce: 'post',
|
|
276
|
-
config:
|
|
278
|
+
config: (config: VitrifyConfig, env) => {
|
|
277
279
|
onBootHooks = config.vitrify?.hooks?.onBoot || []
|
|
278
280
|
onRenderedHooks = config.vitrify?.hooks?.onRendered || []
|
|
279
281
|
onMountedHooks = config.vitrify?.hooks?.onMounted || []
|
|
@@ -283,8 +285,7 @@ export const baseConfig = async ({
|
|
|
283
285
|
sassVariables = config.vitrify?.sass?.variables || {}
|
|
284
286
|
globalSass = config.vitrify?.sass?.global || []
|
|
285
287
|
additionalData = config.vitrify?.sass?.additionalData || []
|
|
286
|
-
|
|
287
|
-
return {}
|
|
288
|
+
return
|
|
288
289
|
},
|
|
289
290
|
configureServer(server) {
|
|
290
291
|
server.middlewares.use('/', (req, res, next) => {
|
|
@@ -294,8 +295,7 @@ export const baseConfig = async ({
|
|
|
294
295
|
},
|
|
295
296
|
configResolved: (config) => {
|
|
296
297
|
if (process.env.DEBUG) {
|
|
297
|
-
console.log(config
|
|
298
|
-
console.log(config.optimizeDeps)
|
|
298
|
+
console.log(config)
|
|
299
299
|
}
|
|
300
300
|
},
|
|
301
301
|
resolveId(id) {
|
|
@@ -398,6 +398,7 @@ export const baseConfig = async ({
|
|
|
398
398
|
config: (config: VitrifyConfig, env) => {
|
|
399
399
|
if (config.vitrify?.productName)
|
|
400
400
|
productName = config.vitrify?.productName
|
|
401
|
+
return
|
|
401
402
|
},
|
|
402
403
|
transformIndexHtml: {
|
|
403
404
|
enforce: 'post',
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { readFileSync } from 'fs'
|
|
2
1
|
import type { Plugin } from 'vite'
|
|
3
2
|
import { resolvePackageData } from 'vite'
|
|
4
3
|
import Components from 'unplugin-vue-components/vite'
|
|
5
|
-
// import { prepareQuasarConf } from './quasar-conf-file.js'
|
|
6
4
|
import type {
|
|
7
|
-
BootFunction,
|
|
8
5
|
OnBootHook,
|
|
9
6
|
OnMountedHook,
|
|
10
7
|
VitrifyConfig
|
|
11
8
|
} from '../vitrify-config.js'
|
|
12
|
-
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
13
|
-
// import { QuasarResolver } from '../resolver.js';
|
|
14
9
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
|
15
10
|
import type { VitrifyPlugin } from './index.js'
|
|
16
|
-
import { getPkgJsonDir, resolve } from '../app-urls.js'
|
|
17
|
-
|
|
18
|
-
// import { resolve } from 'import-meta-resolve'
|
|
19
|
-
|
|
20
11
|
export interface QuasarConf {
|
|
21
12
|
ctx: Record<string, any>
|
|
22
13
|
css: string[]
|
|
@@ -93,20 +84,20 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
93
84
|
name: 'vite-plugin-quasar-transform',
|
|
94
85
|
enforce: 'pre',
|
|
95
86
|
transform: (code, id, options) => {
|
|
96
|
-
const { ssr
|
|
87
|
+
const { ssr } = options || {}
|
|
97
88
|
code = code
|
|
98
89
|
.replaceAll('__QUASAR_SSR__', ssr ? 'true' : 'false')
|
|
99
90
|
.replaceAll(
|
|
100
91
|
'__QUASAR_SSR_SERVER__',
|
|
101
|
-
ssr
|
|
92
|
+
ssr ? '(import.meta.env.SSR === true)' : 'false'
|
|
102
93
|
)
|
|
103
94
|
.replaceAll(
|
|
104
95
|
'__QUASAR_SSR_CLIENT__',
|
|
105
|
-
ssr ? '
|
|
96
|
+
ssr ? '(import.meta.env.SSR === false)' : 'false'
|
|
106
97
|
)
|
|
107
98
|
.replaceAll(
|
|
108
99
|
'__QUASAR_SSR_PWA__',
|
|
109
|
-
ssr && pwa ? '
|
|
100
|
+
ssr && pwa ? '(import.meta.env.SSR === false)' : 'false'
|
|
110
101
|
)
|
|
111
102
|
|
|
112
103
|
return code
|
|
@@ -165,44 +156,10 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
165
156
|
}
|
|
166
157
|
]
|
|
167
158
|
|
|
168
|
-
return {
|
|
169
|
-
vitrify: {
|
|
170
|
-
urls,
|
|
171
|
-
globalCss,
|
|
172
|
-
staticImports: {
|
|
173
|
-
quasar: ['Quasar']
|
|
174
|
-
},
|
|
175
|
-
hooks: {
|
|
176
|
-
onBoot: onBootHooks,
|
|
177
|
-
onMounted: onMountedHooks,
|
|
178
|
-
onRendered: [injectSsrContext]
|
|
179
|
-
},
|
|
180
|
-
sass: {
|
|
181
|
-
global: ['quasar/src/css/index.sass']
|
|
182
|
-
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: 'vite-plugin-quasar',
|
|
190
|
-
enforce: 'post',
|
|
191
|
-
config: async (config: VitrifyConfig, env) => {
|
|
192
|
-
const { quasar, vitrify: { urls } = {} } = config
|
|
193
159
|
if (quasar) quasarConf = quasar
|
|
194
160
|
if (!quasarConf.framework.lang && config.vitrify?.lang)
|
|
195
161
|
quasarConf.framework.lang = config.vitrify.lang
|
|
196
|
-
|
|
197
|
-
// 'package.json',
|
|
198
|
-
// urls?.packages?.quasar
|
|
199
|
-
// ).pathname
|
|
200
|
-
// const { version } = JSON.parse(
|
|
201
|
-
// readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' })
|
|
202
|
-
// )
|
|
203
|
-
// const { version } = await import('quasar/package.json', {
|
|
204
|
-
// assert: { type: 'json' }
|
|
205
|
-
// })
|
|
162
|
+
|
|
206
163
|
/**
|
|
207
164
|
* Importing package.json is problematic
|
|
208
165
|
*/
|
|
@@ -220,53 +177,24 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
220
177
|
}
|
|
221
178
|
|
|
222
179
|
return {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
180
|
+
vitrify: {
|
|
181
|
+
urls,
|
|
182
|
+
globalCss,
|
|
183
|
+
staticImports: {
|
|
184
|
+
quasar: ['Quasar']
|
|
185
|
+
},
|
|
186
|
+
hooks: {
|
|
187
|
+
onBoot: onBootHooks,
|
|
188
|
+
onMounted: onMountedHooks,
|
|
189
|
+
onRendered: [injectSsrContext]
|
|
190
|
+
},
|
|
191
|
+
sass: {
|
|
192
|
+
global: ['quasar/src/css/index.sass']
|
|
193
|
+
// additionalData: [`@import 'quasar/src/css/index.sass'`]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
230
196
|
resolve: {
|
|
231
|
-
// dedupe: ['quasar', '@quasar/extras'],
|
|
232
197
|
alias: [
|
|
233
|
-
// {
|
|
234
|
-
// find: 'quasar/wrappers',
|
|
235
|
-
// replacement: new URL('quasar-wrappers.ts', urls?.cli).pathname
|
|
236
|
-
// },
|
|
237
|
-
// {
|
|
238
|
-
// find: 'quasar/vue-plugin',
|
|
239
|
-
// replacement: new URL(
|
|
240
|
-
// 'src/vue-plugin.js',
|
|
241
|
-
// urls?.packages?.quasar
|
|
242
|
-
// ).pathname
|
|
243
|
-
// },
|
|
244
|
-
// {
|
|
245
|
-
// find: 'quasar/plugins',
|
|
246
|
-
// replacement: new URL('src/plugins.js', urls?.packages?.quasar)
|
|
247
|
-
// .pathname
|
|
248
|
-
// },
|
|
249
|
-
// {
|
|
250
|
-
// find: 'quasar/components',
|
|
251
|
-
// replacement: new URL(
|
|
252
|
-
// 'src/components.js',
|
|
253
|
-
// urls?.packages?.quasar
|
|
254
|
-
// ).pathname
|
|
255
|
-
// },
|
|
256
|
-
// {
|
|
257
|
-
// find: 'quasar/composables',
|
|
258
|
-
// replacement: new URL(
|
|
259
|
-
// 'src/composables.js',
|
|
260
|
-
// urls?.packages?.quasar
|
|
261
|
-
// ).pathname
|
|
262
|
-
// },
|
|
263
|
-
// {
|
|
264
|
-
// find: 'quasar/directives',
|
|
265
|
-
// replacement: new URL(
|
|
266
|
-
// 'src/directives.js',
|
|
267
|
-
// urls?.packages?.quasar
|
|
268
|
-
// ).pathname
|
|
269
|
-
// },
|
|
270
198
|
{
|
|
271
199
|
find: 'quasar/src/',
|
|
272
200
|
replacement: new URL(
|
|
@@ -274,24 +202,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
274
202
|
config.vitrify!.urls!.packages!.quasar
|
|
275
203
|
).pathname
|
|
276
204
|
}
|
|
277
|
-
// {
|
|
278
|
-
// find: 'quasar',
|
|
279
|
-
// replacement: new URL(
|
|
280
|
-
// 'node_modules/quasar',
|
|
281
|
-
// config.vitrify?.urls?.app
|
|
282
|
-
// )
|
|
283
|
-
// }
|
|
284
|
-
// {
|
|
285
|
-
// find: new RegExp('^quasar$'),
|
|
286
|
-
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
287
|
-
// .pathname
|
|
288
|
-
// }
|
|
289
|
-
// {
|
|
290
|
-
// find: `@quasar/extras`,
|
|
291
|
-
// replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
292
|
-
// .pathname
|
|
293
|
-
// }
|
|
294
|
-
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
295
205
|
]
|
|
296
206
|
},
|
|
297
207
|
optimizeDeps: {
|
|
@@ -300,13 +210,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
300
210
|
define: {
|
|
301
211
|
__DEV__: process.env.NODE_ENV !== 'production' || true,
|
|
302
212
|
__QUASAR_VERSION__: `'${version}'`
|
|
303
|
-
// __QUASAR_SSR__: !!ssr,
|
|
304
|
-
// // __QUASAR_SSR_SERVER__: ssr === 'server',
|
|
305
|
-
// __QUASAR_SSR_SERVER__: `import.meta.env.SSR`,
|
|
306
|
-
// // __QUASAR_SSR_CLIENT__: ssr === 'client',
|
|
307
|
-
// __QUASAR_SSR_CLIENT__: `!import.meta.env.SSR`,
|
|
308
|
-
// // __QUASAR_SSR_PWA__: ssr === 'client' && pwa
|
|
309
|
-
// __QUASAR_SSR_PWA__: pwa ? `!import.meta.env.SSR` : false
|
|
310
213
|
},
|
|
311
214
|
ssr: {
|
|
312
215
|
noExternal: ['quasar']
|