-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow array of paths to the preprocessCss phase #1888
Conversation
Note: Due to the way the style plugin registry works, the only way to activate SASS in the tests was to "install" one of the following: registry.add('css', 'broccoli-sass', ['scss', 'sass']);
registry.add('css', 'broccoli-ruby-sass', ['scss', 'sass']); I chose to mock registry.add('css', 'super-sass', ['scss']); .. and then the fixtures would contain Let me know if this is worth doing. |
|
||
return requireLocal(this.name).call(null, [tree], input, output, merge({}, this.options, options)); | ||
var trees = paths.map(function (file) { | ||
var outputName = (file === 'app') ? _this.applicationName : file; // keep backwards compat |
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.
Can you make this multiline please?
I left a couple of comments, but this looks good. Thank you for the tests (mocking in that fixture seems good to me for now). |
I quite like the solution by @MichaelVdheeren in #1816, where it auto builds any non The only downside for this is that you do not have specific control over exactly which files are built, and (for my specific needs) you cannot control which files are built under certain environments. e.g. I set a really tiny scss file to be built in test mode to save time and only one theme to be built in dev mode (because var themes = ['themes/a/theme'];
// use a much faster css in test mode
if (process.env.EMBER_ENV === 'test') {
themes = ['tiny'];
}
if (process.env.EMBER_ENV === 'production') {
themes = themes.concat([
'themes/b/theme',
'themes/c/theme',
'themes/d/theme',
'themes/e/theme',
'themes/f/theme'
]);
}
// later:
preprocessCss: {
options: {
paths: themes
}
}, I wonder if we could use a combination of this PR and #1816. Perhaps default to 'auto' mode, which builds all non partial scss files; and provide the option of passing an array of paths (or a glob pattern) to be more specific: preprocessCss: {
paths: 'auto' // default .. builds anything without a partial _* prefix
},
// or
preprocessCss: {
paths: ['a', 'b', 'c']
} This could work in a predictable way for most users, and allow explicit configuration for those who need more. Ideally, we don't want to decide on one way too hastily and then have to introduce breaking changes later. So your thoughts are welcome. Naturally, documentation is the key. I'm willing to write it, once we know what we are implementing. |
one thing to note is that if we do use an |
Build performance is indeed the biggest problem as I found that using #1816 results in slow builds when you have multiple sass files (in our case for different internet explorers) which import ie bootstrap sass. |
There's even more to it than just the amount of files you're building. The I'm brainstorming ideas on how to get the sass cache to actually work. It seems selectively including files is the way to go, until there are some perf improvements on We can always add the |
@rwjblue I've updated the code based on your comments, let me know if there's anything else. |
one last thing. should we use |
var trees = paths.map(function (file) { | ||
var outputName = file; | ||
if (file === 'app') { | ||
outputName = _this.applicationName; // keep backwards compat |
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 think this needs to be updated per recent changes app.options.outputPaths.css
specifically.
41d958a
to
64db184
Compare
@rwjblue rebased and updated to work with the |
Yeah, I think it makes sense to combine them. My first inclination is that configuring the "inputs" inside your var app = new EmberApp({
paths: {
app: {
css: {
'main': '/css/main.css',
'theme/a': '/css/theme/a.css'
},
js: '/js/app.js'
},
vendor: {
css: '/css/vendor.css',
js: '/js/vendor.js'
},
testSupport: {
css: '/css/test-support.css',
js: '/js/test-support.js'
}
}
}); |
@tstirrat LGTM... (except @rwjblue will prolly have an opinion 🍭 The more I thought about it, the more I think we should stick as close to existing conventions as possible, the most prominent being indeed being grunt. For reference, there are many variations supported by grunt itself, most of which you can see here. We may want to at least consider utilizing the same code that grunt uses under the hood. |
Needs a rebase |
64db184
to
1646adb
Compare
I'm happy to go with the merging into |
I'm still working on this, just really busy at work this week. I'll get a chance over the weekend to finish it. |
I'm working towards this API, as suggested by @jayphelps : var app = new EmberApp({
outputPaths: {
app: {
css: {
'main': '/css/main.css',
'theme/a': '/css/theme/alpha.css'
}
}
}
}); Output paths/filenames will be respected regardless of whether you are using a preprocessor or not. |
Any updates here? |
1646adb
to
b0b3a0e
Compare
made some progress but havent had time to diagnose some failing tests. |
It seems there is some trickery required in merging options below the first level: // defaults in ember-app.js
{
es3Safe: true,
wrapInEval: !isProduction,
outputPaths: {
app: {
css: {
'app': '/assets/' + this.name + '.css'
},
js: '/assets/' + this.name + '.js' // <--- note this
},
vendor: {
css: '/assets/vendor.css',
js: '/assets/vendor.js'
},
testSupport: {
css: '/assets/test-support.css',
js: '/assets/test-support.js'
}
},
// snip
}
// user's Brocfile.js
var app = new EmberApp({
outputPaths: {
app: {
css: {
'main': '/css/main.css',
'theme/a': '/css/theme/a.css'
}
// note: no 'js' key here
}
}
});
// merged options:
{
outputPaths: {
app: {
css: {
'main': '/css/main.css',
'theme/a': '/css/theme/a.css'
}
},
vendor: {
css: '/assets/vendor.css',
js: '/assets/vendor.js'
},
testSupport: {
css: '/assets/test-support.css',
js: '/assets/test-support.js'
}
}
} In this situation, the user would not expect to have to supply the @rwjblue Given that a deep merge will also give undesired results (it will merge the default I'd prefer not to change the options merging stuff, or start a new pattern, without consulting you. |
b0b3a0e
to
de8bf71
Compare
Once we have a correct options merging, this is ready to go from my end |
de8bf71
to
0c58096
Compare
0c58096
to
b2848a3
Compare
@rwjblue I've fixed the options merging issue - with failing test - and rebased. I think this is ready to go. |
sorry for letting this linger, it unfortunately no longer merges cleanly |
@stefanpenner I will rebase |
@tstirrat :) |
this appears to not be a breaking change can you confirm? |
I wrote tests to keep backward compatibility:
Correct me if i am wrong, but this should maintain backwards compat. |
@tstirrat yes it should, thanks :) |
I'm not sure how it will interplay with addon styles. I might need some time to digest those changes. |
@rwjblue could use your eye re: add ons here. |
let me rebase, in doing that, i will probably have to make the appropriate changes to get the addon tests passing. |
I've rebased, the tests pass in isolation .. but I get intermittent errors on seemingly random tests in
This is an addon used in a totally different set of tests. which makes me think the default package.json is not being copied correctly in the fixtures. |
- Ensure backwards compat for app.scss -> <app name>.css
b2848a3
to
5fcd36f
Compare
... perhaps it's an OSX thing. passing fine on travis: https://travis-ci.org/stefanpenner/ember-cli/builds/40491315 @stefanpenner @rwjblue please let me know if there's anything else I can do here. |
Allow array of paths to the preprocessCss phase
Add missing changelog entry for #1888
Allow a hash of files in
outputPaths.app.css
to be passed to the CSS preprocessor.Ensures backwards compatibility so that when no paths are configured;
app/styles/app.scss
will still be written toassets/<app name>.css
Closes #1656.