diff --git a/generate_bootstrap_theme.js b/generate_bootstrap_theme.js index e08d55346d..bb2a121052 100644 --- a/generate_bootstrap_theme.js +++ b/generate_bootstrap_theme.js @@ -1,22 +1,16 @@ const sass = require('node-sass'); const fs = require('fs'); const path = require('path'); -const { get_public_path } = require('./rollup/rollup.utils'); +const { apps_list, get_app_path, get_public_path, get_options_for_scss } = require('./rollup/rollup.utils'); -const node_modules_path = path.resolve(get_public_path('frappe'), 'node_modules'); -const scss_path = path.resolve(get_public_path('frappe'), 'scss'); -const website_theme_path = path.resolve(get_public_path('frappe'), 'website_theme'); -const custom_theme_name = process.argv[2]; +const output_path = process.argv[2]; let scss_content = process.argv[3]; scss_content = scss_content.replace(/\\n/g, '\n'); sass.render({ data: scss_content, - includePaths: [ - node_modules_path, - scss_path - ], + outputStyle: 'compact', importer: function(url) { if (url.startsWith('~')) { // strip ~ so that it can resolve from node_modules @@ -28,16 +22,17 @@ sass.render({ return { file: url }; - } + }, + ...get_options_for_scss() }, function(err, result) { if (err) { console.error(err.formatted); // eslint-disable-line return; } - fs.writeFile(path.resolve(website_theme_path, custom_theme_name), result.css, function(err) { + fs.writeFile(output_path, result.css, function(err) { if (!err) { - console.log(custom_theme_name); // eslint-disable-line + console.log(output_path); // eslint-disable-line } }); }); \ No newline at end of file diff --git a/rollup/config.js b/rollup/config.js index 181fe876d1..f645eae498 100644 --- a/rollup/config.js +++ b/rollup/config.js @@ -20,7 +20,8 @@ const { bench_path, get_public_path, get_app_path, - get_build_json + get_build_json, + get_options_for_scss } = require('./rollup.utils'); function get_rollup_options(output_file, input_files) { @@ -115,12 +116,15 @@ function get_rollup_options_for_css(output_file, input_files) { // less -> css postcss({ extract: output_path, - use: [['less', { - // import other less/css files starting from these folders - paths: [ - path.resolve(get_public_path('frappe'), 'less') - ] - }], 'sass'], + use: [ + ['less', { + // import other less/css files starting from these folders + paths: [ + path.resolve(get_public_path('frappe'), 'less') + ] + }], + ['sass', get_options_for_scss()] + ], include: [ path.resolve(bench_path, '**/*.less'), path.resolve(bench_path, '**/*.scss'), diff --git a/rollup/rollup.utils.js b/rollup/rollup.utils.js index 608d6a5e4d..05aa6d2708 100644 --- a/rollup/rollup.utils.js +++ b/rollup/rollup.utils.js @@ -69,6 +69,18 @@ function run_serially(tasks) { const get_app_path = app => app_paths[app]; +const get_options_for_scss = () => { + const node_modules_path = path.resolve(get_app_path('frappe'), '..', 'node_modules'); + const app_paths = apps_list.map(get_app_path).map(app_path => path.resolve(app_path, '..')); + + return { + includePaths: [ + node_modules_path, + ...app_paths + ] + } +} + module.exports = { sites_path, bundle_map, @@ -80,5 +92,6 @@ module.exports = { assets_path, bench_path, delete_file, - run_serially + run_serially, + get_options_for_scss };