2014-03-28 30 views
2

與所有我寫的其他節點的項目我的文件,這需要一個節點服務器的文件夾沒有根。下面是當前文件夾層次結構:咕嚕醜化無法找到父目錄

- Root/ 
    - build/ 
    - css/ 
    - im/ 
    - js/ 
    - nodeserver/ <-- gruntfile and package are here 

GruntFile.jspackage.json,並且server.js都位於nodeserver/

這裏是我的GruntFile:

module.exports = function(grunt) { 

    // Project configuration. 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 
     uglify: { 
      files: { 
       '../build/all.min.js':['../js/config.js'] 
      }, 
      options: { 
       banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', 
       report: true 
      } 
     } 
    }); 

    // Load the plugin that provides the "uglify" task. 
    grunt.loadNpmTasks('grunt-contrib-uglify'); 

    // Default task(s). 
    grunt.registerTask('default', ['uglify']); 

}; 

當我運行繁重的,它不能找到那我指定的文件。這是迴應:

Running "uglify:files" (uglify) task 
------------------------------------ 
Verifying property uglify.files exists in config...OK 
File: [no files] 
Options: banner="/*! demo-webservice 2014-03-28 */\n", footer="", compress={"warnings":false}, mangle={}, beautify=false, report 

爲什麼不能看到我的js文件?

回答

0

my_target: {}結束語files: {}解決我的問題。

grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 
    uglify: { 
     my_target: { 
      files: { 
       '../build/all.min.js':['../js/config.js'] 
      } 
     }, 
     options: { 
      banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', 
      report: true 
     } 
    } 
}); 

^---該initConfig的新版本。

還應當指出的是,my_target可以是任何東西,並且默認情況下使用,因爲它提供的只是醜化曲線。如果我提供了多個配置文件,即「test:{},prod:{}等:{}」,那麼我將在完成任務後以下列方式引用它們:uglify:test,uglify:prod,uglify:etc