basset
basset copied to clipboard
Less stylesheets: Main linked sheet not recompiled when referenced assets are modified
Given this collection configuration:
$directory = $collection->directory(
'../app/assets/styles',
function ($collection) {
$collection->stylesheet('main.less');
}
);
and a main.less
file specified:
@import "reset.less";
@import "grid.less";
@import "colors.less";
@import "fonts.less";
@import "mixins.less";
//etc
If a child stylesheet is modified (ie. fonts.less
), the only way to trigger a recompile is to do a cold-save (just CTRL+S) on the main.css
.
I´ve currently changed the line $collection->stylesheet('main.less');
for $collection->requireDirectory()
or even a requireTree()
so basset recompiles again, but that leaves my build folder with all imported stylesheets (which in time are baked into the main combined collection)
Is there any other way to overcome this issue right now?
No not without making a save in the main sheet. I've had this as well, don't know if I want Basset to read the file for any child sheets. Would over complicate things.
You could use requireDirectory with only() On 16 Jun 2013 05:15, "Iván N. Paz" [email protected] wrote:
Given this collection configuration:
$directory = $collection->directory( '../app/assets/styles', function ($collection) { $collection->stylesheet('main.less'); });
and a main.less file specified:
@import "reset.less";@import "grid.less";@import "colors.less";@import "fonts.less";@import "mixins.less";//etc
If a child stylesheet is modified (ie. fonts.less), the only way to trigger a recompile is to do a cold-save (just CTRL+S) on the main.css.
I´ve currently changed the line $collection->stylesheet('main.less'); for $collection->requireDirectory() or even a requireTree() so basset recompiles again, but that leaves my build folder with all imported stylesheets (which in time are baked into the main combined collection)
Is there any other way to overcome this issue right now?
— Reply to this email directly or view it on GitHubhttps://github.com/jasonlewis/basset/issues/170 .
The only()
option didn´t work for me sadly (which means, that I could´t get it to work...
Instead went for watchr - https://github.com/mynyml/watchr
I'm in the same situation too bit disappointed it won't pick up children changes. I guess you could put all Less in one master file but i like to split in to nav.less, header.less etc
The only()
option didn't work for me neither...
Instead of searching for children changes, why not implement an opinionated workflow to make the check simpler?
For example:
- All imports should be contained within a partials subfolder
- The partials folder could be specified within the config file to have any name you wanted (imports, partials, components etc...)
- Any time a save occurs, it just has to check if that file exists within the specified foldername. If so, recompile the file in
$collection->stylesheet('');
The way I hacked this is in src/basset/Builder/Builder.php on line 22:
protected $force = false;
Set this to true and it will recompile on every request. Obviously this is a hack solution as I couldn't figure out how to call the setForce() method and it was getting really annoying having to save the main file every time I made a small change.
If you can just update the documentation to tell us how we can call this then we can do something like:
if (Config::get('app.debug')) {
$builder->setForce(true);
}
That would at least be better than what I'm doing now. It makes me feel dirty.
line 22? which version of basset are you running - on 4.0.0 that is on line 43. Agreed though - its a moderately dirty workaround, and although it recompiles the main less/sass stylesheet, it doesn't solve the issue of the parsed view not knowing about the new build collection. So a reload is inevitable...