seitime-frappe/rollup/frappe-html-plugin.js
Faris Ansari 55e5b473d0 Better messages for build commands (#5117)
* Better rollup messages in console

* Remove 'docs folder not found' warning

* Show production message

* fix codacy
2018-03-05 22:07:55 +05:30

26 lines
No EOL
591 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}';
`;
}
};
};