Skip to content

Commit

Permalink
This commit will conserve the html spacing between tags (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssuman authored and devongovett committed Dec 22, 2017
1 parent 5c16471 commit 0f40da9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transforms/posthtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ async function getConfig(asset) {
config.plugins = await loadPlugins(config.plugins, asset.name);

if (asset.options.minify) {
config.plugins.push(htmlnano());
const htmlNanoOptions = {
collapseWhitespace: 'conservative'
};
config.plugins.push(htmlnano(htmlNanoOptions));
}

config.skipParse = true;
Expand Down
9 changes: 9 additions & 0 deletions test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,13 @@ describe('html', function() {
}
}
});

it('should conserve the spacing in the HTML tags', async function() {
await bundle(__dirname + '/integration/html/index.html', {
production: true
});

let html = fs.readFileSync(__dirname + '/dist/index.html', 'utf8');
assert(/<i>hello<\/i> <i>world<\/i>/.test(html));
});
});
1 change: 1 addition & 0 deletions test/integration/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ <h1>Hello world</h1>
<a href="tel:+33636757575">Tel link</a>
<script src="index.js"></script>
<script src="https://unpkg.com/parcel-bundler"></script>
<i>hello</i> <i>world</i>
</body>
</html>

0 comments on commit 0f40da9

Please sign in to comment.