feat: added preserveComments option

This commit is contained in:
Pierre Reimertz 2016-10-10 03:35:03 +02:00 committed by Remy Sharp
parent d53c651921
commit a41ab78a95
9 changed files with 41 additions and 1 deletions

View File

@ -15,6 +15,7 @@ function options(args) {
'skip-absolute-urls',
'videos',
'inlinemin',
'preserve-comments',
],
string: [ // options
'encoding',
@ -32,6 +33,7 @@ function options(args) {
o: 'videos',
m: 'inlinemin',
H: 'header',
c: 'preserve-comments',
},
});
@ -41,6 +43,10 @@ function options(args) {
argv.compressJS = false;
argv.collapseWhitespace = false;
}
if (argv['preserve-comments']) {
argv.preserveComments = true;
}
if (argv['skip-absolute-urls']) {
argv.skipAbsoluteUrls = true;
}

View File

@ -6,5 +6,6 @@ module.exports = function () {
collapseWhitespace: true,
nosvg: false, // by default, DO compress SVG with SVGO
skipAbsoluteUrls: false,
preserveComments: false,
};
};

View File

@ -304,7 +304,12 @@ function main() {
return Promise.all(promises).then(function then() {
var html = '';
inliner.removeComments($(':root')[0], $);
// remove comments
if (!inliner.options.preserveComments) {
inliner.removeComments($(':root')[0], $);
}
// collapse the white space
if (inliner.options.collapseWhitespace) {
$('pre, textarea').each(function () {

View File

@ -0,0 +1,3 @@
{
"preserveComments": false
}

View File

@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline script</title> </head> <body> </body> </html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>inline script</title>
</head>
<body>
<!-- hello -->
</body>
</html>

View File

@ -0,0 +1,3 @@
{
"preserveComments": true
}

View File

@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline script</title> </head> <body> <!-- hello --> </body> </html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>inline script</title>
</head>
<body>
<!-- hello -->
</body>
</html>