fix: handle loading of bundle css & js in website
This commit is contained in:
parent
ede9188aa6
commit
2b549619a8
3 changed files with 14 additions and 4 deletions
|
|
@ -14,7 +14,7 @@ module.exports = {
|
||||||
let dir = path.dirname(out.path);
|
let dir = path.dirname(out.path);
|
||||||
if (out.path.endsWith(".js") && keys.includes(asset_path)) {
|
if (out.path.endsWith(".js") && keys.includes(asset_path)) {
|
||||||
let bundle_css = files[asset_path];
|
let bundle_css = files[asset_path];
|
||||||
let include_css = '\nfrappe.require("' + bundle_css + '");\n';
|
let include_css = '\nfrappe.require("' + bundle_css + '", null, true);\n';
|
||||||
let modified = include_css + out.text;
|
let modified = include_css + out.text;
|
||||||
out.contents = Buffer.from(modified);
|
out.contents = Buffer.from(modified);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import "./jquery-bootstrap";
|
import "./libs.bundle.js";
|
||||||
import "./frappe/class.js";
|
import "./frappe/class.js";
|
||||||
import "./frappe/polyfill.js";
|
import "./frappe/polyfill.js";
|
||||||
import "./lib/moment.js";
|
|
||||||
import "./frappe/provide.js";
|
import "./frappe/provide.js";
|
||||||
import "./frappe/translate.js";
|
import "./frappe/translate.js";
|
||||||
import "./frappe/form/formatters.js";
|
import "./frappe/form/formatters.js";
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,22 @@ $.extend(frappe, {
|
||||||
lang: "en",
|
lang: "en",
|
||||||
},
|
},
|
||||||
_assets_loaded: [],
|
_assets_loaded: [],
|
||||||
require: async function (links, callback) {
|
require: async function (links, callback, from_assets_json = false) {
|
||||||
if (typeof links === "string") {
|
if (typeof links === "string") {
|
||||||
links = [links];
|
links = [links];
|
||||||
}
|
}
|
||||||
for (let link of links) {
|
for (let link of links) {
|
||||||
|
if (from_assets_json) {
|
||||||
|
if (frappe.boot.assets_json) {
|
||||||
|
link = frappe.boot.assets_json[link];
|
||||||
|
} else {
|
||||||
|
let r = await frappe.call("frappe.sessions.get_boot_assets_json");
|
||||||
|
if (r.message) {
|
||||||
|
frappe.boot.assets_json = r.message;
|
||||||
|
link = frappe.boot.assets_json[link];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
await this.add_asset_to_head(link);
|
await this.add_asset_to_head(link);
|
||||||
}
|
}
|
||||||
callback && callback();
|
callback && callback();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue