Merge pull request #5818 from netchampfaris/concat-build
Create a moment bundle and include it in webform
This commit is contained in:
commit
bd2f992dad
4 changed files with 34 additions and 24 deletions
|
|
@ -5,21 +5,21 @@
|
|||
"public/less/website.less",
|
||||
"public/less/avatar.less",
|
||||
"node_modules/highlight.js/styles/zenburn.css",
|
||||
|
||||
"public/js/lib/awesomplete/awesomplete.css",
|
||||
|
||||
"public/less/form.less",
|
||||
"public/less/controls.less",
|
||||
"public/less/chat.less",
|
||||
"public/less/form_grid.less"
|
||||
],
|
||||
"concat:js/moment-bundle.min.js": [
|
||||
"node_modules/moment/min/moment-with-locales.min.js",
|
||||
"node_modules/moment-timezone/builds/moment-timezone-with-data.min.js"
|
||||
],
|
||||
"js/frappe-web.min.js": [
|
||||
"public/js/frappe/class.js",
|
||||
"public/js/frappe/polyfill.js",
|
||||
"public/js/lib/md5.min.js",
|
||||
"public/js/frappe/provide.js",
|
||||
"node_modules/moment/min/moment-with-locales.js",
|
||||
"node_modules/moment-timezone/builds/moment-timezone-with-data.js",
|
||||
"public/js/frappe/format.js",
|
||||
"public/js/frappe/misc/number_format.js",
|
||||
"public/js/frappe/misc/utils.js",
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
"public/css/desk-rtl.css",
|
||||
"public/css/report-rtl.css"
|
||||
],
|
||||
"js/libs.min.js": [
|
||||
"concat:js/libs.min.js": [
|
||||
"public/js/lib/awesomplete/awesomplete.min.js",
|
||||
"public/js/lib/Sortable.min.js",
|
||||
"public/js/lib/jquery/jquery.hotkeys.js",
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@
|
|||
{% block script %}
|
||||
<script type="text/javascript" src="/assets/js/dialog.min.js"></script>
|
||||
<script type="text/javascript" src="/assets/js/control.min.js"></script>
|
||||
<script type="text/javascript" src="/assets/js/moment-bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
window.web_form_settings = {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ const build_for_app = process.argv[2] === '--app' ? process.argv[3] : null;
|
|||
|
||||
show_production_message();
|
||||
ensure_js_css_dirs();
|
||||
build_libs();
|
||||
concatenate_files();
|
||||
create_build_file();
|
||||
|
||||
if (build_for_app) {
|
||||
build_assets_for_app(build_for_app)
|
||||
|
|
@ -65,25 +66,33 @@ function build(inputOptions, outputOptions) {
|
|||
.catch(err => log(chalk.red(err)));
|
||||
}
|
||||
|
||||
function build_libs() {
|
||||
// only concatenates lib files, not processed through rollup
|
||||
function concatenate_files() {
|
||||
// only concatenates files, not processed through rollup
|
||||
|
||||
const files_to_concat = Object.keys(get_build_json('frappe'))
|
||||
.filter(filename => filename.startsWith('concat:'));
|
||||
|
||||
files_to_concat.forEach(output_file => {
|
||||
const input_files = get_build_json('frappe')[output_file];
|
||||
|
||||
const file_content = input_files.map(file_name => {
|
||||
let prefix = get_app_path('frappe');
|
||||
if (file_name.startsWith('node_modules/')) {
|
||||
prefix = path.resolve(get_app_path('frappe'), '..');
|
||||
}
|
||||
const full_path = path.resolve(prefix, file_name);
|
||||
return `/* ${file_name} */\n` + fs.readFileSync(full_path);
|
||||
}).join('\n\n');
|
||||
|
||||
const output_file_path = output_file.slice('concat:'.length);
|
||||
const target_path = path.resolve(assets_path, output_file_path);
|
||||
fs.writeFileSync(target_path, file_content);
|
||||
log(`${chalk.green('✔')} Built ${output_file_path}`);
|
||||
});
|
||||
}
|
||||
|
||||
function create_build_file() {
|
||||
const touch = require('touch');
|
||||
const libs_path = 'js/libs.min.js';
|
||||
const input_files = get_build_json('frappe')[libs_path];
|
||||
|
||||
const libs_content = input_files.map(file_name => {
|
||||
let prefix = get_app_path('frappe');
|
||||
if (file_name.startsWith('node_modules/')) {
|
||||
prefix = path.resolve(get_app_path('frappe'), '..');
|
||||
}
|
||||
const full_path = path.resolve(prefix, file_name);
|
||||
return `/* ${file_name} */\n` + fs.readFileSync(full_path);
|
||||
}).join('\n\n');
|
||||
|
||||
const target_path = path.resolve(assets_path, libs_path);
|
||||
fs.writeFileSync(target_path, libs_content);
|
||||
log(`${chalk.green('✔')} Built ${libs_path}`);
|
||||
touch(path.join(sites_path, '.build'), { force: true });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ function get_options_for(app) {
|
|||
|
||||
return Object.keys(build_json)
|
||||
.map(output_file => {
|
||||
if (output_file.endsWith('libs.min.js')) return null;
|
||||
if (output_file.startsWith('concat:')) return null;
|
||||
|
||||
const input_files = build_json[output_file]
|
||||
.map(input_file => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue