diff --git a/esbuild/sass_options.js b/esbuild/sass_options.js index a2d22c807d..fcc7e04ccd 100644 --- a/esbuild/sass_options.js +++ b/esbuild/sass_options.js @@ -1,7 +1,17 @@ -let { get_options_for_scss } = require("./utils"); +let path = require("path"); +let { get_app_path, app_list } = require("./utils"); + +let node_modules_path = path.resolve( + get_app_path("frappe"), + "..", + "node_modules" +); +let app_paths = app_list + .map(get_app_path) + .map(app_path => path.resolve(app_path, "..")); module.exports = { - ...get_options_for_scss(), + includePaths: [node_modules_path, ...app_paths], importer: function(url) { if (url.startsWith("~")) { // strip ~ so that it can resolve from node_modules diff --git a/esbuild/utils.js b/esbuild/utils.js index f63ddc4119..3261f88c9a 100644 --- a/esbuild/utils.js +++ b/esbuild/utils.js @@ -71,21 +71,6 @@ 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 = app_list - .map(get_app_path) - .map(app_path => path.resolve(app_path, "..")); - - return { - includePaths: [node_modules_path, ...app_paths] - }; -}; - function get_apps_list() { return fs .readFileSync(path.resolve(sites_path, "apps.txt"), { @@ -123,6 +108,5 @@ module.exports = { get_app_path, delete_file, run_serially, - get_options_for_scss, get_cli_arg }; diff --git a/generate_bootstrap_theme.js b/generate_bootstrap_theme.js index 2113d55e11..3672a761f8 100644 --- a/generate_bootstrap_theme.js +++ b/generate_bootstrap_theme.js @@ -1,29 +1,14 @@ const sass = require('node-sass'); const fs = require('fs'); -const path = require('path'); -const { apps_list, get_app_path, get_public_path, get_options_for_scss } = require('./rollup/rollup.utils'); - -const output_path = process.argv[2]; - +const sass_options = require('./esbuild/sass_options'); +let output_path = process.argv[2]; let scss_content = process.argv[3]; scss_content = scss_content.replace(/\\n/g, '\n'); sass.render({ data: scss_content, outputStyle: 'compressed', - importer: function(url) { - if (url.startsWith('~')) { - // strip ~ so that it can resolve from node_modules - return { - file: url.slice(1) - }; - } - // normal file, let it go - return { - file: url - }; - }, - ...get_options_for_scss() + ...sass_options }, function(err, result) { if (err) { console.error(err.formatted); // eslint-disable-line