UNPKG

rollup-plugin-html-literals

Version:
32 lines (28 loc) 824 B
'use strict'; var minifyLiterals = require('minify-literals'); var pluginutils = require('@rollup/pluginutils'); var index = (options = {}) => { if (!options.minifyHTMLLiterals) { options.minifyHTMLLiterals = minifyLiterals.minifyHTMLLiterals; } if (!options.filter) { options.filter = pluginutils.createFilter(options.include, options.exclude); } const minifyOptions = options.options || {}; return { name: "html-literals", transform(code, id) { if (!options.filter(id)) return null; try { return options.minifyHTMLLiterals(code, { ...minifyOptions, fileName: id }); } catch (error) { if (options.failOnError) { this.error(error.message); } else { this.warn(error.message); } } } }; }; module.exports = index;