So I have two different grunt tasks for my site which is generated by Assemble. Throughout my site, the base URL is specified through {{site.url}}. When I generate the production site, this is equal to pburtchaell.com. When I generate the development (local) site, this is equal to localhost:8000.
Whenever I switch between the two tasks, I have to go change the data file these two values are located in. Sometimes I will forget to do this and upload the files to a staging server only to realize {{site.url}} is localhost:8000.
Is there some way to configure my gruntfile to automatically use pburtchaell.com when I run grunt build:production
and use localhost:800 when I run grunt build:development
?
Modify your current build
task look like this, so you can call with build:production
and build:development
:
grunt.task.registerTask('build', function(env) {
// Assuming your load early with site:grunt.file.readYAML or site:grunt.file.readJSON
var site = grunt.config('site'),
// Default if env not specified.
env = env || 'development';
site.url = (env === 'development') ? 'localhost:800' : 'http://pburtchaell.com';
// Change with your existing build task
grunt.task.run('your', 'other', 'task');
});