[英]Grunt plugins not found using load-grunt-config
I've split out my grunt plugins into their own files and I'm using the load-grunt-config ( https://github.com/firstandthird/load-grunt-config ) to call them: 我将grunt插件分成了自己的文件,并使用load-grunt-config( https://github.com/firstandthird/load-grunt-config )来调用它们:
module.exports = function (grunt) {
'use strict';
require('load-grunt-config')(grunt);
};
I've got sass, autoprefixer, cssmin and watch tasks working but I'm also using Browsersync and px-to-rem these two plugins return: 我已经有了sass,autoprefixer,cssmin并观看了工作,但是我还使用Browsersync和px-to-rem这两个插件返回:
Warning: Task "remify" not found. Use --force to continue.
and 和
Warning: Task "browsersync" not found. Use --force to continue.
when called individually or as part of a bigger task. 当单独调用或作为较大任务的一部分调用时。
I've followed the syntax for the separate.js files for these two plugin so I'm at a loss. 我已经遵循了这两个插件的eparate.js文件的语法,所以我很茫然。 For example the remify.js file which is called when running grunt is written like this 例如,运行grunt时调用的remify.js文件是这样编写的
module.exports = {
dist: {
options: {
base: 16,
fallback: true,
fallback_existing_rem: true,
ignore: []
},
files: {
'css/style.css': 'css/style.css'
}
}
};
Any ideas where this is going wrong? 任何想法哪里出问题了?
I've also set up a gist of the example code, include package.json and a aliases.yml 我还设置了示例代码的要点,包括package.json和aliases.yml
https://gist.github.com/sturobson/f88258fd010e901e24d9 https://gist.github.com/sturobson/f88258fd010e901e24d9
You have to call the grunt plugin exactly what it is. 您必须确切地称呼grunt插件。 So where I've got remify
I should be using px_to_rem
and where I've got browsersync
and I should have browserSync
. 那么,我有remify
我应该使用px_to_rem
并在那里我有browsersync
,我应该有browserSync
。
Silly me. 傻我
you can pass a second argument to load-grunt-config
to provide some options where you could also define some pattern which can be used by load-grunt-tasks which is used internally. 您可以将第二个参数传递给load-grunt-config
提供一些选项,您还可以在其中定义一些模式,这些模式可以由内部使用的load-grunt-tasks使用。
if you don't pass a second argument, it uses the default-pattern of load-grunt-tasks which is grunt-*
. 如果不传递第二个参数,它将使用load-grunt-tasks的默认模式grunt-*
。
so if you want to load all devDependencies without defining them seperatly, do it like this: 因此,如果您想加载所有devDependencies而不单独定义它们,请按照以下步骤操作:
require('load-grunt-config')(grunt, {
loadGruntTasks: {
pattern: '*',
scope: 'devDependencies'
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.