Grunt concat输出为空

时间:2014-11-24 15:52:23

标签: javascript node.js gruntjs npm concat

我的concat任务输出是空的,我不明白。 我的Gruntfile

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        concat: {
            dist: {
                src: 'src/js/*.js',
                dest: 'js/main.js'
            }
        }
    });
    // Load Tasks
    grunt.loadNpmTasks('grunt-contrib-concat');

    // Default task.
    grunt.registerTask('default', 'concat');

};

grunt v0.4.5 npm v1.3.14

我使用grunt concat并获得以下消息:

Running "concat:dist" (concat) task
File js/main.js created.

Done, without errors.

但是Outputfile main.js是空的。

这是我的package.json:

{
  "name": "Testing",
  "version": "0.0.0",
  "description": "",
  "main": "Gruntfile.js",
  "dependencies": {
    "bower": "~1.3.12",
    "express": "~4.10.2",
    "grunt-concat-include": "~0.2.4",
    "grunt-cli": "~0.1.13",
    "grunt-contrib": "~0.11.0",
    "grunt": "~0.4.5",
    "grunt-contrib-compass": "~0.7.2",
    "grunt-contrib-coffee": "~0.10.1",
    "grunt-contrib-compress": "~0.8.0",
    "grunt-contrib-connect": "~0.9.0",
    "grunt-contrib-concat": "~0.5.0",
    "grunt-contrib-csslint": "~0.2.0",
    "grunt-contrib-cssmin": "~0.9.0",
    "grunt-contrib-handlebars": "~0.8.0",
    "grunt-contrib-htmlmin": "~0.2.0",
    "grunt-contrib-imagemin": "~0.7.2",
    "grunt-contrib-jade": "~0.11.0",
    "grunt-contrib-jasmine": "~0.6.5",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-jst": "~0.6.0",
    "grunt-contrib-copy": "~0.5.0",
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-less": "~0.11.4",
    "grunt-contrib-requirejs": "~0.4.4",
    "grunt-contrib-qunit": "~0.4.0",
    "grunt-contrib-nodeunit": "~0.3.3",
    "grunt-contrib-sass": "~0.7.4",
    "grunt-contrib-uglify": "~0.4.1",
    "grunt-contrib-stylus": "~0.15.1",
    "grunt-contrib-yuidoc": "~0.5.2",
    "grunt-contrib-symlink": "~0.3.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-dev-update": "~1.0.1",
    "grunt-express-server": "~0.4.19",
    "min": "~0.0.4"
  },
  "devDependencies": {},
  "scripts": {
    "test": "test"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gruntjs/grunt"
  },
  "author": "me",
  "license": "BSD-2-Clause",
  "bugs": {
    "url": "https://github.com/gruntjs/grunt/issues"
  },
  "homepage": "https://github.com/gruntjs/grunt"
}

1 个答案:

答案 0 :(得分:0)

最可能的原因是错误的源路径。一切都必须与Gruntfile的位置有关。就您而言,我的猜测是您的Gruntfile位于src内部,因此您需要从以下位置更改配置:

concat: {
            dist: {
                src: 'src/js/*.js',
                dest: 'js/main.js'
            }
        }

收件人:

concat: {
            dist: {
                src: 'js/*.js',
                dest: 'js/main.js'
            }
        }