我正在尝试构建一个使用基础五个grunt文件的yeoman生成器但是找不到任务。只找到干净的任务。
Warning: Task "concurrent:server" not found. Use --force to continue
相关代码为here,我该如何解决?
答案 0 :(得分:1)
我在尝试重复使用时遇到了类似的问题。一个gruntfile.js。您可能需要从npm安装相关的grunt软件包 - grunt依赖的软件包,但实际上并未安装在您的项目中。在这种情况下,从您的终端,在项目文件夹中:
$ npm install grunt-concurrent
答案 1 :(得分:0)
我能够弄清楚如何将基础5 yeoman发电机应用到我自己的。花了一点力气才弄清楚需要哪些文件和其他配置。显然,除了尝试重用Gruntfile.js之外还有更多内容,因为我不熟悉自己和grunt,所以这并不让我感到惊讶。
以下是我添加到index.js
的一些行var spawn = require('child_process').spawn;
// setup the test-framework property, Gruntfile template will need this
this.testFramework = options['test-framework'] || 'mocha';
// for hooks to resolve on mocha by default
options['test-framework'] = this.testFramework;
// resolved to mocha by default (could be switched to jasmine for instance)
this.hookFor('test-framework', { as: 'app' });
skipMessage: options['skip-install-message']
var webappDir = 'src/main/webapp/html/';
this.template('_Gruntfile.js', webappDir + 'Gruntfile.js');
this.template('_package.json', webappDir + 'package.json');
this.copy('bowerrc', webappDir + '.bowerrc');
this.copy('_bower.json', webappDir + 'bower.json');
this.copy('jshintrc', webappDir + '.jshintrc');
this.copy('editorconfig', webappDir + '.editorconfig');
this.mkdir(webappDir + 'uat');
this.copy('_dalekjs-tests.js', webappDir + 'uat/dalekjs-tests.js');
this.indexFile = this.readFileAsString(path.join(this.sourceRoot(), 'index.html'));
this.indexFile = this.engine(this.indexFile, this);
this.directory('app', webappDir + 'app', true);
this.write(webappDir + 'app/index.html', this.indexFile);
希望这对于有人并且试图将Foundation 5 yeoman生成器代码与他们自己的生成器合并而言非常有用。
答案 2 :(得分:0)
首先从您拥有Gruntfile.js的同一文件夹中安装所有必需的grunt模块:
npm install grunt-concurrent grunt-nodemon --save-dev
其次,通过在Gruntfile.js中定义来加载这个模块
...
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default', [
'concurrent'
]);
现在您已准备好运行任务:
grunt
Bellow你可以看到我用的watch,sass和nodemon的Gruntfile.js的整个例子:
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
project: {
app: ['app'],
assets: ['assets'],
scss: ['<%= project.assets %>/sass/css'],
css: ['<%= project.assets %>/public/css']
},
sass: {
dev: {
options: {
style: 'expanded',
compass: false,
loadPath: 'bower_components'
},
files: {
'<%= project.css %>/style.css': '<%= project.scss %>/style.scss'
}
}
},
watch: {
sass: {
files: '<%= project.scss %>/{,*/}*.{scss,sass}',
tasks: ['sass:dev']
},
},
// watch our node server for changes
nodemon: {
dev: {
script: 'server.js'
}
},
// run watch and nodemon at the same time
concurrent: {
options: {
logConcurrentOutput: true
},
tasks: ['nodemon', 'watch']
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default', [
'concurrent'
]);
};