babel-plugin-template-html-minifier
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -67,3 +67,3 @@ const htmlMinifier = require('html-minifier'); | ||
} while (value.indexOf(id) !== -1); | ||
return '${' + id + ' }'; | ||
return 'babel-plugin-template-html-minifier:' + id; | ||
} | ||
@@ -70,0 +70,0 @@ |
{ | ||
"name": "babel-plugin-template-html-minifier", | ||
"description": "Minify HTML in tagged template strings using html-minifier", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
36
test.js
@@ -20,3 +20,6 @@ import test from 'ava'; | ||
const defaultHtmlMin = { | ||
collapseWhitespace: true | ||
collapseWhitespace: true, | ||
removeComments: true, | ||
minifyCSS: {level: 2}, | ||
minifyJS: true | ||
}; | ||
@@ -30,2 +33,6 @@ | ||
const tickSpan2Trimmed = '`<span class="${classes}" readonly="readonly" disabled="${disabled}">test</span>`'; | ||
const tickSpan3 = '`<span style="${style}" >test</span>`'; | ||
const tickSpan3Trimmed = '`<span style="${style}">test</span>`'; | ||
const tickSpan4 = '`<span onclick=${() => console.log(\'click\')} >test</span>`'; | ||
const tickSpan4Trimmed = '`<span onclick=${()=>console.log(\'click\')}>test</span>`'; | ||
const tickComment = '`<!-- Comment with variable ${myclass} -->`'; | ||
@@ -91,2 +98,29 @@ /* eslint-enable no-template-curly-in-string */ | ||
test('templated style attribute', t => babelTest(t, { | ||
source: `import {html} from 'lit-html'; | ||
html${tickSpan3};`, | ||
result: `import{html}from'lit-html';html${tickSpan3Trimmed};`, | ||
pluginOptions: { | ||
modules: { | ||
'lit-html': ['html'] | ||
}, | ||
htmlMinifier: defaultHtmlMin | ||
} | ||
})); | ||
test('templated event attribute', t => babelTest(t, { | ||
source: `import {html} from 'lit-html'; | ||
html${tickSpan4};`, | ||
result: `import{html}from'lit-html';html${tickSpan4Trimmed};`, | ||
pluginOptions: { | ||
modules: { | ||
'lit-html': ['html'] | ||
}, | ||
htmlMinifier: { | ||
...defaultHtmlMin, | ||
removeAttributeQuotes: true | ||
} | ||
} | ||
})); | ||
test('import of main module file by path specified in package.json', t => babelTest(t, { | ||
@@ -93,0 +127,0 @@ source: `import {html, render} from 'lit-html/${litHtmlMain}'; |
27262
695