Add CSS Inlining to minify.utils
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
c06c7a29ce
commit
f40cb103f8
@ -75,7 +75,7 @@ async function delRegReq(uuid) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
query,
|
query,
|
||||||
increment, // Probqbly doesn't need exporting?
|
//increment, // Probqbly doesn't need exporting?
|
||||||
addUser,
|
addUser,
|
||||||
userAtime,
|
userAtime,
|
||||||
addRegReq,
|
addRegReq,
|
||||||
|
@ -2,7 +2,7 @@ const log = require('../utils/log.utils')
|
|||||||
const crypto = require('crypto')
|
const crypto = require('crypto')
|
||||||
const db = require('../services/dbAccess.services')
|
const db = require('../services/dbAccess.services')
|
||||||
const fs = require('fs/promises')
|
const fs = require('fs/promises')
|
||||||
const minify = require('html-minifier').minify
|
const minify = require('../utils/minify.utils')
|
||||||
|
|
||||||
// Checks users registration key against issued keys
|
// Checks users registration key against issued keys
|
||||||
async function isAuthed(uuid) { // Needs testing
|
async function isAuthed(uuid) { // Needs testing
|
||||||
@ -33,18 +33,15 @@ async function generateKey() { // Needs testing & moving to 'register.utils'
|
|||||||
|
|
||||||
async function generateConfirmationEmail(eml, uuid) {
|
async function generateConfirmationEmail(eml, uuid) {
|
||||||
try {
|
try {
|
||||||
let htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8')
|
const htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8')
|
||||||
let mini = minify(((htmlTpl).replace(/>>ACCESSCODE<</g, uuid)), { // Add collapse whitespace here
|
const htmlStr = htmlTpl.replace(/>>ACCESSCODE<</g, uuid)
|
||||||
removeComments: true,
|
const htmlMin = await minify(htmlStr)
|
||||||
collapseWhitespace: true,
|
const txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8')
|
||||||
minifyCSS: true
|
return {
|
||||||
})
|
|
||||||
let txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8')
|
|
||||||
return { // CSS Needs to be inlined. See css-inline, or css-inliner
|
|
||||||
to: eml,
|
to: eml,
|
||||||
subject: 'OwlBoard Registration',
|
subject: 'OwlBoard Registration',
|
||||||
text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid),
|
text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid),
|
||||||
html: mini
|
html: htmlMin
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
log.out('mailServices.generateConfirmationEmail: Error reading templates, $(err)', 'err')
|
log.out('mailServices.generateConfirmationEmail: Error reading templates, $(err)', 'err')
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
const htmlShrink = require('html-minifier').minify
|
const htmlShrink = require('html-minifier').minify
|
||||||
|
const juice = require('juice')
|
||||||
|
|
||||||
module.exports = async function minifyMail(input) {
|
module.exports = async function minifyMail(input) {
|
||||||
// Minify HTML input, including inline styles.
|
const inlined = juice(input)
|
||||||
//let inline = cssInliner(input) ??
|
return htmlShrink(inlined, {
|
||||||
return htmlShrink(input)
|
removeComments: true,
|
||||||
|
collapseWhitespace: true
|
||||||
|
})
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user