admin管理员组文章数量:1387304
The code
My latest mit is in a repo on GitHub.
The problem...
I am setting up a project (link above) using GruntJS. While trying to run any Grunt task, I'm getting a No "<insert-taskname>" targets found
; a few examples:
No "browserSync" targets found. Warning: Task "browserSync" failed. Use --force to continue.
No "jshint" targets found. Warning: Task "jshint" failed. Use --force to continue.
No "sass" targets found. Warning: Task "sass" failed. Use --force to continue.
What I'm doing
I am using external .js
Grunt config files using the load-grunt-configs plugin. I have used a very similar setup in other projects without problems. I'm passing the shared Grunt variables which were initialized in the Gruntfile.js
to each of the grunt-configs
files using the options
object that is a part of the load-grunt-configs
plugin.
What I've tried so far...
I've tried checking my Grunt variables that are being used in the external config files, double checking my syntax and bracket matching, and searching through other stack overflow questions with no luck.
Any help would be greatly appreciated! Thank you.
The code
My latest mit is in a repo on GitHub.
The problem...
I am setting up a project (link above) using GruntJS. While trying to run any Grunt task, I'm getting a No "<insert-taskname>" targets found
; a few examples:
No "browserSync" targets found. Warning: Task "browserSync" failed. Use --force to continue.
No "jshint" targets found. Warning: Task "jshint" failed. Use --force to continue.
No "sass" targets found. Warning: Task "sass" failed. Use --force to continue.
What I'm doing
I am using external .js
Grunt config files using the load-grunt-configs plugin. I have used a very similar setup in other projects without problems. I'm passing the shared Grunt variables which were initialized in the Gruntfile.js
to each of the grunt-configs
files using the options
object that is a part of the load-grunt-configs
plugin.
What I've tried so far...
I've tried checking my Grunt variables that are being used in the external config files, double checking my syntax and bracket matching, and searching through other stack overflow questions with no luck.
Any help would be greatly appreciated! Thank you.
Share Improve this question edited Apr 19, 2016 at 14:19 qbeauperin 5895 silver badges21 bronze badges asked Aug 16, 2014 at 18:58 user3773571user37735712 Answers
Reset to default 4I remend using the idiomatic and built-in methods of breaking up your Gruntfile instead. 3rd party solutions tend to stray far from the Grunt APIs.
Create a folder named tasks/
and within that folder add files similar to what you're currently doing now.
Load all of those files in your main Gruntfile using grunt.loadTasks()
:
// Gruntfile.js
module.exports = function(grunt) {
// Initialize config.
grunt.initConfig({
pkg: require('./package.json'),
});
// Load per-task config from separate files.
grunt.loadTasks('tasks');
};
Each of those files are formatted like mini Gruntfiles. Here is an example for jshint:
// tasks/jshint.js
module.exports = function(grunt) {
grunt.config('jshint', {
app: {
options: {jshintrc: 'app/.jshintrc'},
src: ['app/**/*.js'],
},
});
grunt.loadNpmTasks('grunt-contrib-jshint');
};
Here is a full example of this solution from the creator of Grunt himself: https://github./cowboy/wesbos
your problem is inside your config tasks.
you are doing
module.exports = {
you need to do:
module.exports.tasks = {
other than that i remend following kyle's answer, as it is much cleaner to use grunt's built in features!
本文标签: javascriptGruntJS setup No targets foundStack Overflow
版权声明:本文标题:javascript - GruntJS setup: No targets found - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744549064a2612072.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论