【问题标题】:Grunt concat output ist emptyGrunt concat 输出为空
【发布时间】:2015-01-22 09:32:45
【问题描述】:

我的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.

但是输出文件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"
}

【问题讨论】:

  • 以防万一...您的src 文件夹中有文件吗?我的意思是src/js/中的一些js文件
  • 没有人有想法/解决方案?
  • 是的,否则将无法工作... concat 创建一个 main.js 文件,但它是空的 :(
  • 我也有同样的问题,还没解决?
  • @ferdynator 我的错。我没有足够的代表来编辑它。可以吗?

标签: javascript node.js gruntjs npm concat


【解决方案1】:

最可能的原因是源路径不正确。一切都必须与 Gruntfile 的位置相对。在您的情况下,我的猜测是您的 Gruntfile 位于您的 src 中,因此您需要从以下位置更改配置:

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

到:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-04
    • 1970-01-01
    • 1970-01-01
    • 2016-09-13
    • 2023-03-28
    • 2018-11-27
    • 1970-01-01
    相关资源
    最近更新 更多