我想構建一個yeoman生成器,它使用基金會五gruntfile但未找到任務。只有乾淨的任務被發現。任務「併發:服務器」找不到
Warning: Task "concurrent:server" not found. Use --force to continue
相關代碼是here,我該如何解決?
我想構建一個yeoman生成器,它使用基金會五gruntfile但未找到任務。只有乾淨的任務被發現。任務「併發:服務器」找不到
Warning: Task "concurrent:server" not found. Use --force to continue
相關代碼是here,我該如何解決?
我能弄清楚如何將我的基金會自動生成器應用到我自己的。花費一點努力才能確定需要哪些文件和其他配置。顯然,除了試圖重用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);
希望這是一個人磨磨蹭蹭,並試圖用自己的發電機合併基金會5自耕農生成代碼有用的線條。
我試圖'重用'gruntfile.js時遇到類似的問題。您可能需要從npm安裝相關的grunt軟件包 - grunt依賴的軟件包,但實際上並未安裝在您的項目中。在這種情況下,從終端,裏面的項目文件夾:
$ NPM安裝咕嚕併發
首先安裝在同一個文件夾,你必須Gruntfile.js所有必要的咕嚕模塊:
npm install grunt-concurrent grunt-nodemon --save-dev
其次,負載該模塊由在Gruntfile.js
...
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default', [
'concurrent'
]);
限定10
現在,您已經準備好運行的任務:
grunt
婁你可以看到手錶,青菜和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'
]);
};