XML components dynamically loaded with builder.load + Webpack bundle #620
Comments
@webleaf currently the dynamicl loading of XML with Below I am going to list the steps taken to enable webpack bundling with dynamically loaded XML components.
var myComponentInstance = builder.load({
path: "~/components",
name: "some-fragment"
});
if ((<any>global).TNS_WEBPACK) {
// Register tns-core-modules UI framework modules
require("bundle-entry-points");
// Register application modules
// This will register each `root`, `page`, `fragment` postfixed xml, css, js, ts, scss file in the app/ folder
const context = (<any>require).context("~/", true, /(root|page|fragment)\.(xml|css|js|ts|scss|less|sass)$/);
global.registerWebpackModules(context);
global.registerModule("components/some-fragment", () => require("./components/some-fragment"));
}
new CopyWebpackPlugin([
{ from: "components/**" },
{ from: "fonts/**" },
{ from: "**/*.jpg" },
{ from: "**/*.png" },
] Update: Test application demonstrating the above can be found here |
@NickIliev thank you for answer. Looks like your solution creates copy of |
@NickIliev I do it so:
Do the trick too. |
Thank you! You saved my day! |
@NickIliev, I have requirement to load view dynamically, however the only difference is, my project is an angular project. Could you please guide me with it? Pointer to any documentation showing how to dynamically load a view using builder.load and {N} 6 (webpack) Thank in anticipation |
I use
builder.load()
to load xml file. It works well. But don't works when I build--bundle
.Because in this case
__dirname
refs tobundle.js
and there are no moresome-fragment.xml
.How implement such loading of xml file for work w/o an w/
--bundle
?The text was updated successfully, but these errors were encountered: