'use strict';

var pluginutils = require('@rollup/pluginutils');
var minifyHtmlLiterals = require('minify-html-literals');

function minifyHTML({ include, exclude, options } = {}) {
    return {
        name: 'minify-html-template-literals',
        transform: (code, id) => {
            if (include || exclude) {
                const filter = pluginutils.createFilter(include, exclude);
                if (!filter(id))
                    return null;
            }
            const result = minifyHtmlLiterals.minifyHTMLLiterals(code, Object.assign({ fileName: id }, options));
            return result ? result.code : null;
        }
    };
}

module.exports = minifyHTML;
