1

したがって、私のサイトにはAssembleによって生成される 2 つの異なる単調なタスクがあります。私のサイト全体で、ベース URL は {{site.url}} で指定されています。本番サイトを生成すると、これは pburtchaell.com と同じです。開発 (ローカル) サイトを生成すると、これは localhost:8000 と同じになります。

2 つのタスクを切り替えるたびに、これら 2 つの値が格納されているデータ ファイルを変更する必要があります。ときどき、これを忘れてファイルをステージング サーバーにアップロードすると、{{site.url}} が localhost であることがわかります。 :8000。

実行時に自動的に pburtchaell.com を使用し、実行時にgrunt build:productionlocalhost:800 を使用するように gruntfile を構成する方法はありますgrunt build:developmentか?

4

1 に答える 1

1

現在のbuildタスクを次のように変更して、 and で呼び出すことができるようにし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');
});
于 2014-03-02T02:53:17.860 に答える