瀏覽代碼

fix: Common scss options for theme generator and rollup scss

version-14
Faris Ansari 6 年之前
父節點
當前提交
698bf208ab
共有 3 個檔案被更改,包括 32 行新增20 行删除
  1. +7
    -12
      generate_bootstrap_theme.js
  2. +11
    -7
      rollup/config.js
  3. +14
    -1
      rollup/rollup.utils.js

+ 7
- 12
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
}
});
});

+ 11
- 7
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'),


+ 14
- 1
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
};

Loading…
取消
儲存