Gruntでファイル内のテキストを一括で置換する
grunt deploy --revision=hogehoge
これがやりたかった
まずは、 Grunt Option API で、コマンドのオプションを設定、取得する
grunt.option('revision') // hogehoge
参考:
http://js.studio-kingdom.com/grunt/api/grunt_option
テキストの置換には grunt-replace を使う
$ npm install grunt-replace --save-dev
Gruntfileの設定は下記のような感じで、置換対象のテキストには'@@'をつけておく。
options: { patterns: [ { match: 'foo', replacement: 'bar', // replaces "@@foo" to "bar" expression: false // simple variable lookup } ] }
Grunt Replace
https://github.com/outaTiME/grunt-replace