Change output folder in debug mode?

96 views
Skip to first unread message

Samuel Milton

unread,
Mar 14, 2013, 5:58:31 AM3/14/13
to squi...@googlegroups.com
Is it possible to change the output folder when site is in debug mode?

When debugging is turned off my combined JS/CSS-files are put in a release folder with .Render("/release/main.css"), but when in debug mode I haven't found a way to do this.

I want something like .RenderDebug("/dev/main.css")

Is this possible?

Alex Ullrich

unread,
Mar 17, 2013, 2:53:53 PM3/17/13
to squi...@googlegroups.com
What is your use case for this?  I don't really see enough value in this to include it in the core library but am open to convincing.

To implement on your own, I think extension methods off the bundle classes would be your best bet.  Something like:

public static string CustomRender(this CSSBundle bundle, string outputFile) {
    string location = DebugCheck() ? (_debugPrefix + outputFile) : (_productionPrefix + outputFile);
    return bundle.Render(location);
}

You would have to define rules to dictate how paths should actually be combined and how to tell if you are debugging or not.

Hope this helps,

Alex

Samuel Milton

unread,
Mar 18, 2013, 4:09:25 AM3/18/13
to squi...@googlegroups.com
Thanks for your input Alex!

When thinking about it just now i have two arguments.

1) SquishIt generated files are mixed with my source CSS/LESS-files. In our project, a quite large e-commerce site in over 50 languages, we have about 35 LESS-files in out /ui/css-folder. As I like to keep my CSS modular. A majority of these files are bundled in to a single "main.css". But, I also create separate bundles for sections the visitors not always is going to, eg "My profile", "Check out"-process and so on. Each of these extra bundles also creates a generated *.css file in my /ui/css/ folder where they are mixed with my "original" CSS files. When I go to release mode I render all bundles to /ui/release/css/ and it would be nice to render my debug files to /ui/dev/css/ to keep them separated from my source files.

2) More foolproof development/testing. Lets say you specify a path to a background image in your /ui/css/header.css file. The image is in the /ui/img/ folder, so you specify the path by doing background-image: url(../img/header.png). This will work when in development mode. But when you go to release this will fail since the CSS-file now is in the /ui/release/css/ folder and the browser will look for the background image in the /ui/release/img/ folder. By being able to specify a development output folder I think these types of bugs could be easier to spot.

Other than these two above I think that all the arguments for having the possibility to render the production code to a separate folder would also apply for doing the same to development code.

Best regards, Samuel

Samuel Milton

unread,
Mar 18, 2013, 4:17:35 AM3/18/13
to squi...@googlegroups.com
3) It's easier to ignore an entire folder (eg /ui/dev/*) in the CVS than individual files (eg /ui/css/shoppingcart.less.squishit.debug.css, /ui/css/checkout.less.squishit.debug.css) in a folder where they are mixed with my source files.

K. Adam White

unread,
Mar 18, 2013, 10:23:03 AM3/18/13
to squi...@googlegroups.com
I can see your reasoning for this, but I'd like to propose an alternative (if parallel) methodology: What if the debug files were rendered to the release directory? That way the .debug.css files would be at the same level as the final release-mode ones, and you could exclude just that entire directory within your VCS. I'm operating on the assumption that since SquishIt generates files on-demand on the server, technically you don't have any reason to store the compiled styles in source control; obviously this wouldn't work if you have a need to version-control the release-mode files.

(As an aside, at least with Git it's easy to ignore *.debug.css files by extension -- does your VCS not permit exclusion by partial file name match?)
On Mon, Mar 18, 2013 at 4:17 AM, Samuel Milton <samuel....@gmail.com> wrote:
3) It's easier to ignore an entire folder (eg /ui/dev/*) in the CVS than individual files (eg /ui/css/shoppingcart.less.squishit.debug.css, /ui/css/checkout.less.squishit.debug.css) in a folder where they are mixed with my source files.

--
You received this message because you are subscribed to the Google Groups "SquishIt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to squishit+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Samuel Milton

unread,
May 18, 2013, 2:25:07 AM5/18/13
to squi...@googlegroups.com
"What if the debug files were rendered to the release directory?"

That would be very good. If you can control it yourself, like with a .DebugToReleaseFolder() or something :)

Reply all
Reply to author
Forward
0 new messages