vitrify 0.10.5 → 0.10.6
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fastifyStatic from '@fastify/static';
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
|
-
import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js';
|
|
4
3
|
import { appendToHead } from '../../helpers/utils.js';
|
|
5
4
|
const fastifySsrPlugin = async (fastify, options, done) => {
|
|
6
5
|
options.baseUrl = options.baseUrl || '/';
|
|
@@ -84,14 +83,11 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
84
83
|
catch (e) {
|
|
85
84
|
manifest = {};
|
|
86
85
|
}
|
|
87
|
-
const cssModules = [entryUrl]
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
const css = collectCss({
|
|
93
|
-
mods: matchedModules
|
|
94
|
-
});
|
|
86
|
+
// const cssModules = [entryUrl]
|
|
87
|
+
// const matchedModules = componentsModules(cssModules, vite!)
|
|
88
|
+
// const css = collectCss({
|
|
89
|
+
// mods: matchedModules
|
|
90
|
+
// })
|
|
95
91
|
const [appHtml, preloadLinks] = await render(url, manifest, ssrContext);
|
|
96
92
|
if (!ssrContext.initialState)
|
|
97
93
|
ssrContext.initialState = {};
|
|
@@ -99,7 +95,7 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
99
95
|
let html = template
|
|
100
96
|
.replace(`<!--app-html-->`, appHtml)
|
|
101
97
|
.replace('<!--product-name-->', options.productName || 'Product name')
|
|
102
|
-
.replace('<!--dev-ssr-css-->', css)
|
|
98
|
+
// .replace('<!--dev-ssr-css-->', css)
|
|
103
99
|
.replace('<!--initial-state-->', `<script>
|
|
104
100
|
__INITIAL_STATE__ = '${JSON.stringify(ssrContext.initialState)}'
|
|
105
101
|
</script>`);
|
package/dist/index.js
CHANGED
|
@@ -202,16 +202,21 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
202
202
|
name: 'vitrify-transforms',
|
|
203
203
|
enforce: 'pre',
|
|
204
204
|
transform: (code, id) => {
|
|
205
|
-
if (['main.ts', 'vitrify'].every((val) => id.includes(val))) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
205
|
+
// if (['main.ts', 'vitrify'].every((val) => id.includes(val))) {
|
|
206
|
+
// code =
|
|
207
|
+
// `${globalCss.map((css) => `import '${css}'`).join('\n')}\n` + code
|
|
208
|
+
// }
|
|
209
209
|
if (['RootComponent.vue', 'vitrify'].every((val) => id.includes(val))) {
|
|
210
|
+
const css = `${globalCss
|
|
211
|
+
.map((css) => `@import '${css}';`)
|
|
212
|
+
.join('\n')}\n`;
|
|
210
213
|
const sass = [
|
|
211
214
|
...Object.entries(sassVariables).map(([key, value]) => `${key}: ${value}`),
|
|
212
215
|
...globalSass.map((sass) => `@import '${sass}'`)
|
|
213
216
|
].join('\n');
|
|
214
|
-
code = code
|
|
217
|
+
code = code
|
|
218
|
+
.replace(/<style>(.*?)<\/style>/, '<style>' + css + '</style>')
|
|
219
|
+
.replace(/<style lang="sass">(.*?)<\/style>/, '<style lang="sass">' + sass + '</style>');
|
|
215
220
|
// code = code.replace(/<\/style>/, sass + '</style>')
|
|
216
221
|
}
|
|
217
222
|
return code;
|
package/package.json
CHANGED
|
@@ -125,14 +125,11 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
125
125
|
manifest = {}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
const cssModules = [entryUrl]
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
const css = collectCss({
|
|
134
|
-
mods: matchedModules
|
|
135
|
-
})
|
|
128
|
+
// const cssModules = [entryUrl]
|
|
129
|
+
// const matchedModules = componentsModules(cssModules, vite!)
|
|
130
|
+
// const css = collectCss({
|
|
131
|
+
// mods: matchedModules
|
|
132
|
+
// })
|
|
136
133
|
|
|
137
134
|
const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
|
|
138
135
|
|
|
@@ -142,7 +139,7 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
142
139
|
let html = template
|
|
143
140
|
.replace(`<!--app-html-->`, appHtml)
|
|
144
141
|
.replace('<!--product-name-->', options.productName || 'Product name')
|
|
145
|
-
.replace('<!--dev-ssr-css-->', css)
|
|
142
|
+
// .replace('<!--dev-ssr-css-->', css)
|
|
146
143
|
.replace(
|
|
147
144
|
'<!--initial-state-->',
|
|
148
145
|
`<script>
|
package/src/node/index.ts
CHANGED
|
@@ -274,21 +274,27 @@ export const baseConfig = async ({
|
|
|
274
274
|
name: 'vitrify-transforms',
|
|
275
275
|
enforce: 'pre',
|
|
276
276
|
transform: (code, id) => {
|
|
277
|
-
if (['main.ts', 'vitrify'].every((val) => id.includes(val))) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
277
|
+
// if (['main.ts', 'vitrify'].every((val) => id.includes(val))) {
|
|
278
|
+
// code =
|
|
279
|
+
// `${globalCss.map((css) => `import '${css}'`).join('\n')}\n` + code
|
|
280
|
+
// }
|
|
281
281
|
if (['RootComponent.vue', 'vitrify'].every((val) => id.includes(val))) {
|
|
282
|
+
const css = `${globalCss
|
|
283
|
+
.map((css) => `@import '${css}';`)
|
|
284
|
+
.join('\n')}\n`
|
|
285
|
+
|
|
282
286
|
const sass = [
|
|
283
287
|
...Object.entries(sassVariables).map(
|
|
284
288
|
([key, value]) => `${key}: ${value}`
|
|
285
289
|
),
|
|
286
290
|
...globalSass.map((sass) => `@import '${sass}'`)
|
|
287
291
|
].join('\n')
|
|
288
|
-
code = code
|
|
289
|
-
/<style
|
|
290
|
-
|
|
291
|
-
|
|
292
|
+
code = code
|
|
293
|
+
.replace(/<style>(.*?)<\/style>/, '<style>' + css + '</style>')
|
|
294
|
+
.replace(
|
|
295
|
+
/<style lang="sass">(.*?)<\/style>/,
|
|
296
|
+
'<style lang="sass">' + sass + '</style>'
|
|
297
|
+
)
|
|
292
298
|
// code = code.replace(/<\/style>/, sass + '</style>')
|
|
293
299
|
}
|
|
294
300
|
return code
|