Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Feat: add plugin to support android/ios styleUrls #47

Merged
merged 2 commits into from
Jan 5, 2017

Conversation

sis0k0
Copy link
Contributor

@sis0k0 sis0k0 commented Jan 5, 2017

When given an url "./style.css" and the resource "style.css" does not
exist in the current directory, the plugin will change the url to
"style.android|ios.css". The target platform should be provided in the
options of the plugin.

Closes #36

When given an url "./style.css" and the resource "style.css" does not
exist in the current directory, the plugin will change the url to
"style.android|ios.css". The target platform should be provided in the
options of the plugin.

Closes #36
Copy link
Contributor

@hdeshev hdeshev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

StyleUrlResolvePlugin.prototype.traversePropertyElements = function(property) {
property.initializer.elements
.filter(el => this.notPlatformUrl(el.text))
.filter(el => this.noCommonFile(el.text))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not rename this to "multiplatform" or "regular" file?

return !fs.existsSync(stylePath);
}

StyleUrlResolvePlugin.prototype.replaceStyleUrlsValue = function(element) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use a regex here 😁

compiler.plugin("make", (compilation, callback) => {
const aotPlugin = getAotPlugin(compilation);
aotPlugin._program.getSourceFiles()
.map(sf => this.setCurrentDirectory(sf))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one looks unnecessary. usePlatformStyleUrl does its own setCurrentDirectory

@sis0k0 sis0k0 merged commit be12c23 into master Jan 5, 2017
@sis0k0 sis0k0 deleted the style-urls-plugin branch January 5, 2017 15:23
@sis0k0 sis0k0 mentioned this pull request Mar 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants