teamcfadvance / cfstatic

CfStatic is a framework for managing the inclusion and packaging of CSS and JavaScript in CFML applications.
https://teamcfadvance.github.io/cfstatic
MIT License
102 stars 35 forks source link

Feature Request - Force recompile via URL Parameter #36

Closed ghost closed 12 years ago

ghost commented 12 years ago

The ?debug=1 feature alone is super handy, but the more I rely on using Less, the more I struggle with recompilation. Anytime I use @import in my less files to pull in code, changes to those imported files don't trigger recompilation. I have to save the file containing the @import directive before the recompile will catch my changes.

It'd be awesome if we could specify a URL parameter that would force it. Even if ?debug=1 were augmented to also recompile, that'd work fine for my needs.

DominicWatson commented 12 years ago

Would it be even better to recompile all Less files when any of their dependencies changed?

In the meantime, there is an option to force recompiling on startup. I have that set to true in local development and would reinit the app under those circumstances. On Apr 5, 2012 10:06 PM, "Jason Beam" < reply@reply.github.com> wrote:

The ?debug=1 feature alone is super handy, but the more I rely on using Less, the more I struggle with recompilation. Anytime I use @import in my less files to pull in code, changes to those imported files don't trigger recompilation. I have to save the file containing the @import directive before the recompile will catch my changes.

It'd be awesome if we could specify a URL parameter that would force it. Even if ?debug=1 were augmented to also recompile, that'd work fine for my needs.


Reply to this email directly or view it on GitHub: https://github.com/DominicWatson/cfstatic/issues/36

ghost commented 12 years ago

Hi Dominic,

That would be a good thing, too. However, Less uses @import to make mixins and variables available across less files so there aren't any dependencies being set. It's when these files are changed that I'd like to trigger recompilation.

Jason Beam Blue River Interactive Group www.blueriver.com www.getmura.com

-----Original Message----- From: Dominic Watson [mailto:reply@reply.github.com] Sent: Monday, April 09, 2012 9:59 AM To: Jason Beam Subject: Re: [cfstatic] Feature Request - Force recompile via URL Parameter (#36)

Would it be even better to recompile all Less files when any of their dependencies changed?

In the meantime, there is an option to force recompiling on startup. I have that set to true in local development and would reinit the app under those circumstances. On Apr 5, 2012 10:06 PM, "Jason Beam" < reply@reply.github.com> wrote:

The ?debug=1 feature alone is super handy, but the more I rely on using Less, the more I struggle with recompilation. Anytime I use @import in my less files to pull in code, changes to those imported files don't trigger recompilation. I have to save the file containing the @import directive before the recompile will catch my changes.

It'd be awesome if we could specify a URL parameter that would force it. Even if ?debug=1 were augmented to also recompile, that'd work fine for my needs.


Reply to this email directly or view it on GitHub: https://github.com/DominicWatson/cfstatic/issues/36


Reply to this email directly or view it on GitHub: https://github.com/DominicWatson/cfstatic/issues/36#issuecomment-5028776

DominicWatson commented 12 years ago

Absolutely, nothing to stop cfstatic figuring those @import dependencies out though. I think a url flag for recompiling might also be good though weary of adding features that might not be necessary (ie if the less dependencies were detected)

ghost commented 12 years ago

I wonder if it could even just be part of just ?debug=true - maybe? If in debug, don't concatenate and recompile less?

Just a thought :)

Jason Beam Blue River Interactive Group www.blueriver.com www.getmura.com

-----Original Message----- From: Dominic Watson [mailto:reply@reply.github.com] Sent: Monday, April 09, 2012 10:19 AM To: Jason Beam Subject: Re: [cfstatic] Feature Request - Force recompile via URL Parameter (#36)

Absolutely, nothing to stop cfstatic figuring those @import dependencies out though. I think a url flag for recompiling might also be good though weary of adding features that might not be necessary (ie if the less dependencies were detected)


Reply to this email directly or view it on GitHub: https://github.com/DominicWatson/cfstatic/issues/36#issuecomment-5029159

DominicWatson commented 12 years ago

@beamerweb The latest tagged release (0.4.3) gives you the ability to configure a list of .LESS files that will be imported into all other LESS files (lessGlobals). CfStatic will automatically check for updates to these files and recompile if necessary. Would this fix this issue for you, or would you still need to @import global files on a file by file basis (in which case CfStatic might no auto recompile)?

ghost commented 12 years ago

Hey Dominic - this sounds like a handy feature, but @import global files on a file by file basis would be ideal since when launching to production these files would then no longer need to be recompiled on every refresh.

After some further thought, it'd be REALLY cool if we could do debug=1 and have it be "sticky" for that browser session. Debug would do all the usual things, plus force recompilation of @imported files as well. Right now, the way I force this is to touch the files that @import the changed files so that it recompiles them.

For example, my main .less file uses an @import for some font faces or colors or other mixins. I also have a typography file that is used by Mura CMS's wysiwyg editor - typography.less also uses @import for the same colors and mixins so that both i can reuse my colors, mixins or font faces throughout various less files. While in development, I'm changing these imported files quite often without making other changes.

It sounds like this latest feature could be handy for files that might constantly change and that could be pretty useful in many cases. Thanks for that!

DominicWatson commented 12 years ago

I believe that, if you need to use @import for files that have their own specific imports (that other LESS files don't need) - CfStatic should take care of figuring out that your imported files have changed. After all, there's a flag that says, checkForUpdates - the problem is that it is not thorough enough and the best solution would be for it to do its job properly. I've coded up a solution on the train this morning to detect for changes to imported files and it works for me - I'll get it pushed up with tests asap so you can check it out.

There should be no reason for any recompiling on production after first compilation. The default configuration, made for production, ensures that an update check is only made on the initial startup of CfStatic. CfStatic should not be initialized every request ( it should most likely be persisted in the Application scope). Each subsequent request then, has minimal processing from CfStatic; only figuring out which includes to render and this process is based on a cached mapping making for minimal processing.

The new lessGlobals option should be used to specify global LESS includes that will be included in every single LESS file to prevent repetative @import code, it was not designed specifically to watch for changes to those global LESS files, it was just a handy side effect.

Having debug=true sticky on sessions is defo a good idea, though it might best be implemented by calling code so that CfStatic does not need to assume anything about the session scope. You could do something like this for now and I'll think about a good way to have the core do it:

if ( StructKeyExists( url, 'debug' ) ) {
    session.cfstaticDebug = url.debug;
} else if (StructKeyExists( session, 'cfstaticDebug' ) {
    url.debug = session.cfstaticDebug;
}

Anyways, I'll get the latest changes up asap, let me know what you think.

DominicWatson commented 12 years ago

The latest version should now check for changes to imported LESS files automatically. Let me know if it works for you and I'll get ready to tag a new minor release :)

ghost commented 12 years ago

Yep - just grabbed the latest and made a change to a file that is only ever @import-ed and it updated right away. This is perfect, Dom!

DominicWatson commented 12 years ago

Sw33t, thanks for reporting the issue :)