Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Marty Hitchcock
Marty Hitchcock
13,108 Points

How to use concatenated files for production only

I am currently using Grunt to concat my css files each time I do a git commit. However, that means between commits when I am working on something I will not be able to see the changes.

Is there a way to change between:

<link href='css/production.css' rel='stylesheet'>

and

<link href='css/header.css' rel='stylesheet'>
<link href='css/app.css' rel='stylesheet'>
etc

I can get the trigger as to WHEN to make the change, I just don't know HOW to change the links.

Can I hear some explanations on how other people change their concatenated files etc between development and production? Unsure if i'm doing it right.

David Bath
David Bath
25,939 Points

I don't know how you would do that without using a Grunt plugin like usemin, which will replace the lines in the HTML like you want. But that seems more complicated than is necessary. Why don't you just set up a watch task in the Gulpfile that will run the css concatenation whenever you save a file?

Marty Hitchcock
Marty Hitchcock
13,108 Points

Yeah I thought about that but seemed over kill to constantly run a command prompt window just for that and there must be an easier way. But I guess it is just one of those things.