前回のエントリーから引き続いて今度は、複数フォルダを監視してcoffeescirptをコンパイルしてminifyする方法について
下記のコマンドを実行してcontrib-uglifyをインストール
npm install grunt-contrib-uglify --save-devで下のようにGruntfile.coffeeを修正する
module.exports = (grunt)-> grunt.initConfig pkg : grunt.file.readJSON 'package.json' watch : coffee_test1: files : "test1/*.coffee" tasks : ["coffee:test1","uglify:test1"] coffee_test2: files : "test2/*.coffee" tasks : "coffee:test2" coffee : test1: files : [ expand : true cwd : "./test1" src : "*.coffee" dest : "./test1/src/" ext : ".js" ] test2: files : [ expand : true cwd : "./test2" src : '*.coffee' dest : "./test2/src/" ext : ".js" ] uglify : test1: files: [ expand: true cwd: "./test1/src" src: "*.js" dest: "./test1/src/" ext: ".min.js" ] test2: files: [ expand: true cwd: "./test2/src" src: "*.js" dest: "./test2/src/" ext: ".min.js" ] grunt.loadNpmTasks 'grunt-contrib-coffee' grunt.loadNpmTasks 'grunt-contrib-watch' grunt.loadNpmTasks 'grunt-contrib-uglify' grunt.registerTask 'default', ['watch'] returnで、上の通り実行したらminifyされたー、やったー。
参考
GruntでCoffee Scriptのコンパイル&Uglifyで圧縮
0 コメント:
コメントを投稿