Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Implemented platform-specific templateUrl #155

Merged

Conversation

Copy link
Contributor

@EddyVerbruggen EddyVerbruggen commented May 16, 2017

Hi,

This implements #75.

I was trying to webpack my Angular app which has a few components with the structure as shown in this screenshot:

screen shot 2017年05月16日 at 19 55 19

So there's no article-item.html, but there are article-item.ios.html and article-item.android.html.

As you may know using <ios></ios><android></android> in article-item.html does not work (reliably) in Angular apps so using that workaround (mentioned in #75) doesn't help me out.

So I copy-pasted the css file resolver (which works great!) and applied that to the view files. Now the approach in the screenshot works for non-webpack and webpack NativeScript-Angular projects.

Thanks for considering,
Eddy

spike1292 reacted with thumbs up emoji triniwiz reacted with heart emoji
Copy link
Contributor

sis0k0 commented May 25, 2017

@EddyVerbruggen,

Can you extract the common logic from the two loaders?

Copy link
Contributor Author

EddyVerbruggen commented May 26, 2017
edited
Loading

Hi @sis0k0, yes.. I can take one of these approaches, do you have a perference?

  • Keep it as 2 files, add a 'superclass' and inherit as much as possible (I'd need to override 2 functions (traversePropertyElements and isStyleUrls) in each concrete class, as well as wire up prototype inheritance).
  • Just use 1 plugin file and make those 2 functions work with both types (view and css).

I think the latter is less code and has better performance as it only needs to traverse the entire tree once.

Copy link
Contributor

sis0k0 commented May 26, 2017

I would suggest refactoring it into a single plugin which has two options obj: { resolveStylesUrls: boolean, resolveTemplateUrls: boolean }. If you have any problems, ping me in the community slack :)

Copy link
Contributor Author

A downside of not merging the PR as is, is that it will break backward compatibility as folks now have new nsWebpack.StyleUrlResolvePlugin({platform}) in their webpack.config. That would still work fine if we implement the first option I mentioned though. WDYT?

Copy link
Contributor

sis0k0 commented May 26, 2017

We can deprecate it and even remove it from the webpack config on postinstall.

... opt out of (the default) platform replacement strategy.
Copy link
Contributor Author

Hi @sis0k0, I've just pushed a change to bring all this code back to 1 file, and offer the option to opt out of replacing either css or html files.

Copy link
Contributor

sis0k0 commented May 26, 2017

Looks good :). I'll add postinstall step to replace the old plugin in the user's webpack config.

EddyVerbruggen reacted with thumbs up emoji

Copy link
Contributor

sis0k0 commented May 29, 2017

Eddy, check out EddyVerbruggen#1 :)

EddyVerbruggen reacted with hooray emoji

feat: postinstall replaces StyleUrlResolvePlugin with UrlResolvePlugin
Copy link
Contributor Author

Post install script works great ✅

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /