@quasar/ssr-helpers
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -6,2 +6,4 @@ /* | ||
const { extname } = require('path') | ||
const serialize = require('serialize-javascript') | ||
const createBundle = require('./lib/create-bundle') | ||
@@ -107,3 +109,14 @@ | ||
function renderScripts(renderContext, usedAsyncFiles) { | ||
const autoRemove = 'var currentScript=document.currentScript;currentScript.parentNode.removeChild(currentScript)' | ||
function renderVuexState (ssrContext, nonce) { | ||
if (ssrContext.state !== void 0) { | ||
const state = serialize(ssrContext.state, { isJSON: true }) | ||
return `<script${nonce}>window.__INITIAL_STATE__=${state};${autoRemove}</script>` | ||
} | ||
return '' | ||
} | ||
function renderScripts(renderContext, usedAsyncFiles, nonce) { | ||
if (renderContext.preloadFiles.length > 0) { | ||
@@ -114,3 +127,3 @@ const initial = renderContext.preloadFiles.filter(({ file }) => jsRE.test(file)) | ||
return [ initial[0] ].concat(async, initial.slice(1)) | ||
.map(({ file }) => `<script src="${renderContext.publicPath}${file}" defer></script>`) | ||
.map(({ file }) => `<script${nonce} src="${renderContext.publicPath}${file}" defer></script>`) | ||
.join('') | ||
@@ -154,6 +167,13 @@ } | ||
const nonce = ssrContext.nonce !== void 0 | ||
? ` nonce="${ ssrContext.nonce }" ` | ||
: '' | ||
Object.assign(ssrContext._meta, { | ||
resourceApp, | ||
resourceStyles: renderStyles(renderContext, usedAsyncFiles, ssrContext), | ||
resourceScripts: renderScripts(renderContext, usedAsyncFiles) | ||
resourceScripts: ( | ||
renderVuexState(ssrContext, nonce) | ||
+ renderScripts(renderContext, usedAsyncFiles, nonce) | ||
) | ||
}) | ||
@@ -160,0 +180,0 @@ |
{ | ||
"name": "@quasar/ssr-helpers", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Quasar Framework helper package for SSR", | ||
@@ -28,4 +28,5 @@ "author": { | ||
"dependencies": { | ||
"hash-sum": "^2.0.0" | ||
"hash-sum": "^2.0.0", | ||
"serialize-javascript": "^5.0.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16212
440
2
+ Addedserialize-javascript@^5.0.1
+ Addedrandombytes@2.1.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedserialize-javascript@5.0.1(transitive)