From 57f621f1d8c83abbf3242885bf7020047d4fcf4e Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 1 Mar 2018 15:50:36 +0530 Subject: [PATCH] Clear css file before building (#5108) --- rollup.config.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 8782ce8bba..a5e0c46686 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -112,13 +112,17 @@ function get_js_config(output_file, input_files) { } function get_css_config(output_file, input_files) { + const output_path = path.resolve(assets_path, output_file); + + // clear css file to avoid appending problem + delete_file(output_path); const plugins = [ // enables array of inputs multi_entry(), // less -> css less({ - output: path.resolve(assets_path, output_file), + output: output_path, option: { // so that other .less files can import variables.less from frappe directly paths: [path.resolve(get_public_path('frappe'), 'less')], @@ -155,7 +159,7 @@ function ensure_js_css_dirs() { const files = fs.readdirSync(css_path); files.forEach(file => { - fs.unlinkSync(path.resolve(css_path, file)); + delete_file(path.resolve(css_path, file)); }); } @@ -191,4 +195,10 @@ function get_build_json(app) { } } +function delete_file(path) { + if (fs.existsSync(path)) { + fs.unlinkSync(path); + } +} + module.exports = get_all_apps_config(); \ No newline at end of file