-
-
Notifications
You must be signed in to change notification settings - Fork 40
webpack buggy behaviour while loading templates by require() #11
Comments
I'm struggling to show up my icon fonts, such as FontAwesome. I believe this is a related issue. Are you using FontAwesome in your app? |
What are you using to show them? Actually webpack doesn't care about fonts because the code that loads the font into the fontcache is running on absolute dynamic paths extracted from the css font-family directives. Here you can find the file resolution: On my system resolves to (I set .fa class font-family to FontAwesome, fontawesome-webfont):
The webpack build creates a bundle and sets package.json main to point to that file but it still copies all the files you have inside your project (which is in my opinion stupid, what's the point in using webpack then..). Considering that you get the fonts copied and loaded it should work out of the box. The problem for me is that it doesn't work with "\uCODE" notation anyway.. Even without webpack I have to use real unicode characters pasted or the pipe from nativescript-ng2-fonticon which translates your "fa-CODE" classes to real unicode characters. Anyway you can find an example with webpack and a working icon in the homepage here. It is preconfigured with the required loaders in case it would be needed but it is not at the moment. |
Ah, unfortunately I cannot test on ios because I don't have a mac and didn't setup a VM environment yet.. Anyway the font loading should not depend on webpack, but maybe for ios it is different.. You can try enabling the trace module by adding this to your code:
|
Hey, @ntrp, thanks for digging in here! I hadn't gotten to bundling HTML files yet. Anyway, I did some experiments and here's what I found out:
That said, here's my var bundler = require("nativescript-dev-webpack");
var path = require("path");
module.exports = bundler.getConfig({
resolveLoader: {
root: path.join(__dirname, "node_modules")
},
module: {
loaders: [
{
test: /\.html$/,
loader: "html"
}
]
}
}); |
webpack bundling doesn't work for templateUrl properties, out of the box it works only for inline string templates like this;
I also tried to use the standard webpack pattern:
and I have installed the html-loader but webpack complains that it cannot find the module because it is resolving it form the component path:
The only way to fix this is to add a resolverAlias after the config has been generated:
and then require the template prefixing the loader type:
I also tried to add a loader configuration so I don't have to prefix every require with html!:
but that doesn't work, probably because the scripts aren't merging well the config and setting a module property deletes the other loaders preconfigured..
You can find a working example here:
nativescript-ng2-drawer-seed
Just run:
The text was updated successfully, but these errors were encountered: