Build Profiles with Grunt (Node.js)

Just sharing a few ways of creating build profiles for web projects.

1. Client-side Javascript (Non-Grunt)
A boolean flag in the Javascript determines whether to load dev vs. prod files and resources. A bit ugly but an easy way to switch between multiple build profiles. The next two methods are cleaner and achieve the same results.

2. Cheerio Grunt Plugin
Use cheerio to manipulate the html file(s) to load dev vs. prod files and resources. Create a Grunt task that finds the CSS and Script tags and replace the href with the appropriate files.

3. Jade Templating Engine
Use jade to generate the html file(s) that load dev vs. prod files and resources. Use grunt-contrib-jade to pass in data to generate the files for the appropriate environment.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s