我正在尝试构建一个使用基础五 gruntfile 但未找到任务的 yeoman 生成器。仅找到 clean 任务。
Warning: Task "concurrent:server" not found. Use --force to continue
相关代码在这里,我该如何解决?
我正在尝试构建一个使用基础五 gruntfile 但未找到任务的 yeoman 生成器。仅找到 clean 任务。
Warning: Task "concurrent:server" not found. Use --force to continue
相关代码在这里,我该如何解决?
我在尝试“重用”gruntfile.js 时遇到了类似的问题。您可能需要从 npm 安装相关的 grunt 包 - grunt 所依赖的包,但实际上并未安装在您的项目中。在这种情况下,从您的终端,在项目文件夹中:
$ npm install grunt-concurrent
我能够弄清楚如何将基础 5 yeoman 生成器应用于我自己的。花了一点力气弄清楚需要哪些文件和其他配置。显然,它不仅仅是尝试重用 Gruntfile.js,这并不让我感到惊讶,因为我是 yeoman 和 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 生成器代码与他们自己的生成器合并的人有用。
首先从您拥有 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
下面你可以看到我拥有的带有 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'
]);
};