seitime-frappe/rollup/frappe-html-plugin.js
Faris Ansari 9f5a129333
Rollup Fixes (#5232)
- Use PostCSS instead of Less plugin
- Fixes CSS append problem
- Show which css file changed instead of rollup.manifest.css
- Minify CSS in production
- Cannot import less/css files in js files, put them in build.json
- Let's avoid major changes in Frappe Framework now :)
2018-03-20 13:51:53 +05:30

26 lines
592 B
JavaScript

const path = require('path');
function scrub_html_template(content) {
content = content.replace(/\s/g, ' ');
content = content.replace(/(<!--.*?-->)/g, '');
return content.replace("'", "\'"); // eslint-disable-line
}
module.exports = function frappe_html() {
return {
name: 'frappe-html',
transform(code, id) {
if (!id.endsWith('.html')) return null;
var filepath = path.basename(id).split('.');
filepath.splice(-1);
var key = filepath.join(".");
var content = scrub_html_template(code);
return `
frappe.templates['${key}'] = '${content}';
`;
}
};
};