Javascript 在不同的grunt任务中使用特定数据

Javascript 在不同的grunt任务中使用特定数据,javascript,gruntjs,assemble,Javascript,Gruntjs,Assemble,因此,我的站点有两个不同的grunt任务,它们是由生成的。在我的整个站点中,基本URL是通过{{site.URL}指定的。当我生成生产站点时,这等于pburtchaell.com。当我生成开发(本地)站点时,这等于localhost:8000 每当我在两个任务之间切换时,我必须更改这两个值所在的数据文件。有时,我会忘记这样做,并将文件上载到登台服务器,结果发现{{site.url}}是localhost:8000 是否有某种方法可以将我的GrunFile配置为在运行grunt build:pro

因此,我的站点有两个不同的grunt任务,它们是由生成的。在我的整个站点中,基本URL是通过{{site.URL}指定的。当我生成生产站点时,这等于pburtchaell.com。当我生成开发(本地)站点时,这等于localhost:8000

每当我在两个任务之间切换时,我必须更改这两个值所在的数据文件。有时,我会忘记这样做,并将文件上载到登台服务器,结果发现{{site.url}}是localhost:8000


是否有某种方法可以将我的GrunFile配置为在运行
grunt build:production
时自动使用pburtchaell.com,并在运行
grunt build:development
时使用localhost:800

修改当前的
build
任务,如下所示,您可以使用
build:production
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');
});