咕噜需要configuration属性丢失
设置一个新的项目,将有多个grunt任务,我想从任务文件加载。
当运行我的第一个任务,“核心”,这应该是build立该网站的核心CSS,我得到一个错误,我似乎无法解决。 一直在做一些Googlesearch,没有find这个具体问题。 任何有相同错误信息的问题通常都是OP中input错误或错位花括号的结果。 不知道这是这种情况,但也许别人看到我显然没有看到。
Gruntfile.js
module.exports = function(grunt) { grunt.initConfig({ pkg: require('./package.json') }); grunt.loadTasks('grunt-tasks'); };
咕噜任务/咕噜-core.js
module.exports = function (grunt) { grunt.loadNpmTasks('grunt-sass'); grunt.config('core', { sass : { options : { sourceMap : true, includePaths : 'node_modules/bootstrap-sass/assets/stylesheets' }, dist : { files : { 'main.css' : 'main.scss' } } } }); grunt.registerTask('core', ['sass:dist']); };
错误:
$ grunt core Running "sass:dist" (sass) task Verifying property sass.dist exists in config...ERROR >> Unable to process task. Warning: Required config property "sass.dist" missing. Use --force to continue. Aborted due to warnings.
我尝试了一些不同的东西。 如果我将registerTask更改为:
grunt.registerTask('core', ['sass']);
我得到这个错误:
$ grunt core >> No "sass" targets found. Warning: Task "sass" failed. Use --force to continue. Aborted due to warnings.
不知道这是否相关,但这里是package.json和我正在使用的系统上的一些规格。
Mac OSX Yosemite node version v5.10.1 npm 3.8.3
的package.json
{ "name": "TEST", "version": "1.0.0", "description": "test test test", "main": "Gruntfile.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "https://github.com/path/to/repo" }, "author": "me <me@example.com>", "license": "ISC", "bugs": { "url": "https://github.com/path/to/repo/issues" }, "homepage": "https://github.com/path/to/repo", "devDependencies": { "angular": "^1.5.5", "bootstrap-sass": "^3.3.6", "grunt": "^1.0.1", "grunt-contrib-jshint": "^1.0.0", "grunt-contrib-uglify": "^1.0.1", "grunt-contrib-watch": "^1.0.0", "grunt-sass": "^1.1.0", "jquery": "^2.2.3", "sass-lint": "^1.5.1" }, "dependencies": { "jquery": "^2.2.3" } }
看起来像是我的用户错误。
在任务文件中,我有grunt.config(),但我应该有grunt.initConfig()
var taskConfig = { sass : { options : { sourceMap : true, includePaths : 'node_modules/bootstrap-sass/assets/stylesheets' }, dist : { files : { 'main.css' : 'main.scss' } } }, concat : { core : { src : ['node_modules/jquery/dist/jquery.js', 'js/main.js'], dest : "../dev/js/main.js" } } }; module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-sass'); grunt.initConfig(taskConfig); grunt.registerTask('core', ['concat:core','sass']); };