6

Gruntfile.jsいくつかの今後のプロジェクトのベースをまとめる作業に取り組んでいます。新しいコンピューターで開始するため、すべてが新しいビルドになっています。Homebrew を使用して Node と NPM をインストールし、Grunt をローカル ディレクトリだけでなくグローバルにインストールしました。

これが私のものpackage.jsonです:

{
  "name": "timespent-prototype",
  "version": "0.1.0",
  "devDependencies": {
    "assemble": "0.4.37",
    "bower": "^1.4.1",
    "grunt": "^0.4.5",
    "grunt-contrib-concat": "^0.5.1",
    "grunt-contrib-sass": "^0.9.2",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-newer": "^1.1.0",
    "grunt-wiredep": "^2.0.0"
  }
}

そして、ここに私のものがありますGruntfile.js

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    concat: {
      vendor: {
       src: ['vendor/**/*.min.js'],
       dest: 'build/javascripts/library.js',
      }
    },

    // Takes your scss files and compiles them to css
    sass: {
      dist: {
        options: {
          style: 'expanded'
        },
        files: {
          'build/stylesheets/application.css': 'app/stylesheets/application/index.scss'
        }
      }
    },

    // Assembles your templates into HTML files
    assemble: {
      options: {
        layoutdir: 'app/views/layouts/',
        partials: ['app/views/partials/*.hbs'],
        flatten: true,
        expand: true
      },
      pages: {
        src: ['app/views/**/*.hbs','!app/views/layouts/*.hbs','!app/views/partials/*.hbs'],
        dest: 'build/'
      }
    },

    wiredep: {
      task: {
        src: ['app/views/layouts/*.hbs']
      }
    },

    // Watches for file changes, runs the default task
    watch: {
      files: ['app/**/*'],
      tasks: ['default'],
      options: {
        // Start another live reload server on port 1337
        livereload: 1337,
      }
    }

  });

  // Load the plugins
  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-newer');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-wiredep');

  // Register the tasks
  grunt.registerTask('default', ['sass','assemble']);
  grunt.registerTask('watch', ['watch']);
  grunt.registerTask('concat', ['concat']);
  grunt.registerTask('wiredep', ['wiredep']);
};

私が見ている問題は、複数のタスク、ここでは特に and を使用するwiredepconcat、タスクがループに陥って終了しないことです。grunt concat次のような詳細な出力で実行します。

Registering "grunt-contrib-concat" local Npm module tasks.
Reading /Users/jacksonlynch/projects/timespent-prototype/node_modules/grunt-contrib-concat/package.json...OK
Parsing /Users/jacksonlynch/projects/timespent-prototype/node_modules/grunt-contrib-concat/package.json...OK
Loading "concat.js" tasks...OK
+ concat

Running tasks: concat

Running "concat" task

Running "concat" task

Running "concat" task

Running "concat" task

Running "concat" task

Running "concat" task

Running "concat" task停止するまでどこで印刷を続けますか。複数のプラグインとタスクでこれを確認しているため、NPM または Grunt のインストールに問題がある可能性がありますが、これをデバッグするのに非常に苦労しています。誰かが以前にこれに遭遇したことがある場合は、何が助けになったか教えてください!

ありがとう!


編集: Alireza Ahmadi のコメントに応えて、私のファイル構造は次のとおりです。

.
|
|_ app/
  |_ assets/
  |_ javascript/
  |_ stylesheets/
  |_ views/
|
|_ build/
  |_stylesheets/
  |_javascripts/
|
|_ vendor/
|_ bower.json
|_ Gruntfile.js
|_ package.json
4

1 に答える 1

18

の最後の 2 行でandタスクGruntfile.jsを再宣言しました。grunt がコードを実行しようとすると、concat が未定義の concat タスクを参照するため、無限ループに陥ります。したがって、これらの行を削除する必要があります。concatwiredep

grunt.registerTask('concat', ['concat']);
grunt.registerTask('wiredep', ['wiredep']);

foobar一般に、 で名前を付けたタスクを定義するとgrunt.initConfig、 を使用して定義され、登録する必要がなくregisterTask、コマンドでアクセスできますgrunt foobar

于 2015-06-06T22:10:12.647 に答える