Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (debug) console.info ("Minifying inline CSS: " + insideCSSTag);
processed += csso.justDoIt (token[1]);
} else {
processed += token[1];
}
break;
}
} while (token[0]);
if (SHOW_PRE_MINIFIED_HTML) {
console.info ("-------- PRE-MINIFIED HTML --------");
console.info (processed);
console.info ("-----------------------------------");
}
var minified = html_minifier.minify (processed, {
removeComments: true,
removeCommentsFromCDATA: true,
removeCDATASectionsFromCDATA: true,
collapseWhitespace: false, /* we really want the "collapse into a single space" version of this */
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeEmptyElements: false
});
if (provisional) return {value: minified, provisional: true};
else return minified;
};
const ko = '^w';
tlog.info(' ^w[^:%s^:%s^:%s^:^w]^: %s',
s.view ? ok + 'v' : ko + '-',
s.css ? ok + 's' : ko + '-',
s.controller ? ok + 'c' : ko + '-',
'^:' + key
);
}
tlog.info();
postProcessed = true;
} else {
tlog.overwrite();
}
if (zuixConfig.build.minify != null && zuixConfig.build.minify !== false && zuixConfig.build.minify.disable !== true) {
tlog.overwrite(' ^r*^: minify');
page.content = minify(page.content, zuixConfig.build.minify);
tlog.overwrite(' ^G\u2713^: minify');
}
} else {
tlog.overwrite();
}
if (isStaticSite) {
tlog.info(' ^G\u2713^: static-site content').br();
postProcessed = true;
}
if (zuixConfig.build.esLint) {
// run ESlint
if (page.file.endsWith('.js')) {
tlog.info(' ^r*^: lint');
const issues = linter.verify(page.content, lintConfig, page.file);
minifyHtml (html) {
let minificationOptions = this.options.build.html.minify
// Legacy: Override minification options with generate.minify if present
// TODO: Remove in Nuxt version 3
if (typeof this.options.generate.minify !== 'undefined') {
minificationOptions = this.options.generate.minify
consola.warn('generate.minify has been deprecated and will be removed in the next major version.' +
' Use build.html.minify instead!')
}
if (!minificationOptions) {
return html
}
return htmlMinifier.minify(html, minificationOptions)
}
}
it('should replace class selectors in a normal html file', () => {
replaceHtmlMacro(
'.jp-block {} .jp-block__element {}',
minify(fs.readFileSync(path.join(fixturesCwd, '/html/index.html'), 'utf8'), { collapseWhitespace: true }),
minify(fs.readFileSync(path.join(resultsCwd, '/html/index.only.html'), 'utf8'), { collapseWhitespace: true }),
);
});
function formatHTML(html) {
return victorica(minify(html, {
caseSensitive: true,
collapseWhitespace: true,
}), {
space: "\t",
removeSelfClose: false,
});
}
async function buildHtml() {
console.log('buildHtml()');
var html = await fs.readFileAsync('./src/index.html', 'utf-8');
var monstersList = renderMonstersList(monsterSummaries,
0, initialWindowSize);
html = html.replace('<ul id="monsters-list"></ul>',
toHtml(monstersList));
var monsterDetailHtml = renderMonsterDetailView(bulbasaur);
html = html.replace('<div id="detail-view"></div>',
toHtml(monsterDetailHtml));
if (!debug) {
html = await inlineCriticalCss(html);
html = await inlineVendorJs(html);
html = minifyHtml(html, {removeAttributeQuotes: true});
}
await fs.writeFileAsync('./www/index.html', html, 'utf-8');
}
function copyFile(file, destFile, destDir, cwd, fs, htmlMnify) {
var _fs = require('fs');
if (!fs || !fs.writeFileSync) {
fs = _fs;
}
var ori = join(cwd, file);
var target = join(destDir, destFile);
if (fs.mkdirpSync) {
fs.mkdirpSync(dirname(target));
} else {
require('mkdirp')(dirname(target));
}
var oriFile = htmlMnify && /\.(htm|html)$/.test(ori) ? minify(_fs.readFileSync(ori, 'utf8'), {
removeComments: true,
removeCommentsFromCDATA: true,
collapseWhitespace: true,
minifyCSS: true,
minifyJS: true
}) : _fs.readFileSync(ori);
var err = fs.writeFileSync(target, oriFile);
if (err) {
log.error('copy', err);
} else {
log.info('copy', file, 'to', destFile);
}
return err;
}
p: (data) => {
if (data && data instanceof Object) {
if (
global.inject.clients[this.project.id][this.token] &&
global.inject.clients[this.project.id][this.token].watchers
) {
if (data.dom && global.config.compression) {
try {
let minfied = minify(data.dom, {
removeAttributeQuotes: true,
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
html5: true,
minifyCSS: true,
minifyJS: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
removeTagWhitespace: true,
trimCustomFragments: true,
useShortDoctype: true
})
NgifyHtmlStreamReader.prototype._getOutput = function () {
var settings = this._settings;
var html = minify(
this._chunks.join('').replace(/\r?\n|\r/g, " "),
settings.getValue('htmlMinifyArgs')
);
var htmlName = settings.getValue('htmlName');
return format(
settings.getValue('moduleTemplate') +
settings.getValue('htmlTemplate'),
{
html: html.replace(/'/g, "\\'"),
moduleName: settings.getValue('moduleName'),
htmlName: htmlName
}
) + "\nmodule.exports = '" + htmlName + "';";
};
const findUp = require('find-up');
const { minify } = require('html-minifier');
let configFile = findUp.sync('lego.js');
let config = {
collapseWhitespace: true,
minifyJS: true,
minifyCSS: true,
removeComments: true
};
if (configFile) {
config = Object.assign(config, require(configFile).htmlMinifier);
}
return minify(html, config);
} catch (error) {
throw error;
}
}