Skip to content

Commit

Permalink
use more popular minifier
Browse files Browse the repository at this point in the history
  • Loading branch information
vwochnik committed Nov 16, 2017
1 parent 7672952 commit cc24294
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"README.md"
],
"dependencies": {
"htmlclean": "^3.0.3",
"html-minifier": "^3.5.6",
"lodash": "^4.9.0",
"lodash-es": "^4.9.0",
"rollup-pluginutils": "^1.3.1"
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { extname } from 'path';
import { createFilter } from 'rollup-pluginutils';

import template from 'lodash/template';
import htmlclean from 'htmlclean';
import { minify as minifyHtml } from 'html-minifier';


export default function( options = {} ) {
Expand All @@ -12,9 +12,9 @@ export default function( options = {} ) {

const templateOptions = options.templateOptions || { variable: 'data' };

const useHtmlclean = options.htmlclean || false;
const minify = options.minify || false;

const htmlcleanOptions = options.htmlcleanOptions || { };
const minifyOptions = options.minifyOptions || { };

return {
transform( code, id ) {
Expand All @@ -26,8 +26,8 @@ export default function( options = {} ) {
return null;
}

if ( useHtmlclean ) {
code = htmlclean(code, htmlcleanOptions);
if ( minify ) {
code = minifyHtml(code, minifyOptions);
}

const tpl = template( code, templateOptions );
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe( 'rollup-plugin-jst', () => {
it( 'compiles a component - htmlclean', () => {
return rollup({
entry: 'sample/c.ejs',
plugins: [ jst({ htmlclean: true }) ]
plugins: [ jst({ minify: true, minifyOptions: { collapseWhitespace: true } }) ]
}).then( executeBundle );
});
});

0 comments on commit cc24294

Please sign in to comment.