@bitgenics/fab-static
Advanced tools
Comparing version 0.5.1 to 0.5.2-alpha.0
@@ -54,7 +54,6 @@ const path = require('path') | ||
const initCode = | ||
'var ENV_SETTINGS = {{settings}}\n \ | ||
window.EnvSettings = ENV_SETTINGS\n \ | ||
var CSP_NONCE = "{{nonce}}"\n \ | ||
window.CspNonce = CSP_NONCE\n' | ||
const initCode = ` | ||
window.ENV_SETTINGS = JSON.parse("<%=settings%>") | ||
window.CSP_NONCE = "<%=nonce%>" | ||
` | ||
@@ -65,12 +64,15 @@ const transformHtml = async (file, src, dest) => { | ||
}) | ||
let escaped = html.replace(/({{)/g, '\\{\\{') | ||
escaped = escaped.replace(/(}})/g, '\\}\\}') | ||
const $ = cheerio.load(escaped) | ||
$('head').prepend( | ||
`<script type="application/javascript">${initCode}</script>` | ||
) | ||
$('script').attr('nonce', '{{nonce}}') | ||
// let escaped = html.replace(/({{)/g, '\\{\\{') | ||
// escaped = escaped.replace(/(}})/g, '\\}\\}') | ||
// const $ = cheerio.load(html) | ||
// $('head').prepend( | ||
// `<script type="application/javascript">${initCode}</script>` | ||
// ) | ||
// $('script').attr('nonce', '{{nonce}}') | ||
const js = templ($.html()) | ||
// const js = templ($.html()) | ||
const js = templ(html) | ||
const jsFile = path.resolve(dest, `${file}.js`) | ||
await fse.ensureFile(jsFile) | ||
await fse.writeFile(jsFile, js) | ||
@@ -77,0 +79,0 @@ return jsFile |
{ | ||
"name": "@bitgenics/fab-static", | ||
"version": "0.5.1", | ||
"version": "0.5.2-alpha.0", | ||
"description": "Front-end Application Bundle generator for (mostly) static applications.", | ||
@@ -16,5 +16,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"chalk": "^2.4.1", | ||
"cheerio": "^1.0.0-rc.2", | ||
"deterministic-zip": "^1.0.5", | ||
"fs-extra": "^7.0.0", | ||
"fs-extra": "^7.0.1", | ||
"globby": "^8.0.1", | ||
@@ -21,0 +22,0 @@ "mime-types": "^2.1.19", |
@@ -30,5 +30,5 @@ const StringToBuffer = (str) => { | ||
const code = `const text = [] | ||
${text.filter((item) => item).join('\n')} | ||
text[${text.length}] = Buffer.from('${StringToBuffer(rest)}', 'base64') | ||
const code = `const text = [ | ||
Buffer.from('${StringToBuffer(content)}', 'base64') | ||
] | ||
@@ -35,0 +35,0 @@ const renderToStream = (out, data) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
468
119371
7
17
+ Addedchalk@^2.4.1
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
Updatedfs-extra@^7.0.1