-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with styles in addon directory #56 #57
Conversation
i'll try to make time later this week to review this. |
function isAddonTree(inputPath) { | ||
return inputPath === "/"; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should be at the bottom of the file.
I'm okay with this solution, but only if it relies on stable behaviour from ember-cli. What do you think @stefanpenner? |
c158fda
to
0519fb5
Compare
0519fb5
to
c9d1382
Compare
@stefanpenner any feedback? |
haven't had a chance yet |
// When ember-cli preprocess addon style the inputPath is '/', | ||
// add the '/addon/styles' to try found addon sass files | ||
var root = isAddonTree(inputPath) ? tree : "."; | ||
var filePath = path.join(root, inputPath, file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dukex this line is throwing an error when I try to build an application that uses an addon with this branch:
TypeError: Arguments to path.join must be strings
at Object.posix.join (path.js:488:13)
at tryFile (node_modules/ember-cli-sass/index.js:43:25)
where root
evaluated to { read: [Function], cleanup: [Function] }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have submitted a PR dukex#1 to fix the mentioned issue.
``` TypeError: Arguments to path.join must be strings at Object.posix.join (path.js:488:13) at tryFile (/path/to/app-name/node_modules/addon-name/node_modules/ember-cli-sass/index.js:43:25) at /path/to/app-name/node_modules/addon-name/node_modules/ember-cli-sass/index.js:26:15 ``` The root of the error is that `ember-cli` passes different `tree` as the parameter to `toTree()`. When building an addon that directly uses `ember-cli-sass`, `tree` is a `String` that contains `"/path/to/your/addon-name/addon/styles"`. When building an hosting app that indirectly uses `ember-cli-sass` through an addon, `tree` is an object with a `read()` function that returns `"/path/to/your/addon-name/addon/styles"`.
Fixed error when building an hosting app that indirectly uses ember-cli-sass through an addon.
Thanks @justin-lau! |
Verified that this pull request works perfectly with ember-cli for preprocessing SASS. :) Thanks so much. |
Is there anything the consuming app needs to be doing in order for this PR to work? It works from the dummy app provided by a developing addon, but vendor.css is empty if I consume the developing addon through an external app. To elaborate:
Am I missing some part of the solution?
|
Below is what works for me:
|
I'm sorry. It was a common mistake on my part. I used Just in case someone repeats my mistake, the full list of steps to get it working:
// index.js for 'some-addon'
module.exports = {
name: 'some-addon',
included: function(app) {
this._super.included(app);
}
}
"devDependencies": {
...
"some-addon": "*"
}
|
Perfect walkthrough @begedin. |
+1 |
@justin-lau found I bug in windows, I'll check @justin-lau's pull request and remove the '[WIP]' prefix |
Solved cross platform issue.
@vitch do you got same error without |
Without the extension option when compiling the addons dummy app with this branch I get:
|
@vitch I will investigate it |
@dukex If this issue is resolved, will that also solve ember-cli/ember-cli#2905? |
@vitch I fix it! Update the repository and check again Sorry delay |
@sandstrom I believe not, the ember-cli/ember-cli#2905 example app don't uses ember-cli-sass and this pull request don't has effect in that example |
I've gotta say that I think this is really an issue with ember-cli, and it looks that ember-cli/ember-cli#3344 fixes the problem in ember-cli. This PR seems to introduce quite a bit of coupling to ember-cli internals, so I'd prefer to wait until the underlying issue is resolved in ember-cli. In the meantime addon authors can simply specify the |
@aexmachina "In the meantime addon authors can simply specify the extension option as a workaround." That's not accurate. That is another issue which this pull request doesn't address. The only way my files get preprocessed is if I specify the |
Aha, okay thanks for the info. I will reopen and review tomorrow. On Tue, 11 Aug 2015 23:48 Alex Houchens notifications@github.com wrote:
|
Great thanks @aexmachina! |
@@ -33,8 +33,36 @@ SASSPlugin.prototype.toTree = function(tree, inputPath, outputPath, inputOptions | |||
}, []); | |||
|
|||
function tryFile(file) { | |||
var filePath = path.join('.', inputPath, file); | |||
return fs.existsSync(filePath) ? filePath : false; | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-asterisk **
denotes JSDoc, so this should be a single asterisk.
@stefanpenner any feedback on this? It seems quite tied to implementation details in ember-cli, but I'm happy to go with your advice on this. |
I believe the ember-cli/ember-cli#3344 will help us to remove this hack |
I've asked @rwjblue for an opinion on whether we should add this hack or wait for the underlying issues to be fixed in ember-cli. |
I tried to run ember-cli/ember-cli#3344 but many tests are failed |
Hi there, when will this pull request supposed be merged into master? |
We're trying to avoid merging this, because it's basically a hack to get around a problem in ember-cli which should be fixed when ember-cli/ember-cli#3344 is merged. @stefanpenner should we just merge this and then pull it out when the problem in ember-cli is resolved? |
cc @rwjblue whats the status if your fix? |
Closing in favor of #78 |
I don't know if this approach is the better way to fix the issues, maybe I need understand more about broccoli and ember-cli internals functions, but It's fix the problems(in ember-cli-sass) mentioned on ember-cli/ember-cli#4084 and fix issue #56
For understand why I made this checks please see @stefanpenner anwser on ember-cli/ember-cli#4258