pattern.indexof is not a function报错,用grunt usemin编译的,求大神解答,谢谢

gruntjs - grunt-contrib-copy error (Error code: ENOENT) - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I searched internet and it looks only me had this problem with grunt-contrib-copy.
gruntfile.js
-&pic1.png
-&pic2.png
Result I expected:
gruntfile.js
-&pic1.png
-&pic2.png
-&pic1.png
-&pic2.png
In another word, just copy files in /project/app/img to /project/app/dist/img.
Here is my copy config, which is NOT working:
src: ['*.*'],
expend: true,
cwd: 'app/img/',
dest: 'app/dist/img/'
Here is error message:
Warning: Unable to read "download.png" file (Error code: ENOENT). Use --force to continue.
(download.png is the name of picture file)
How should I config the copy option? Thank you!
It looks like you have a typo, it should be expand instead of expend. So the cwd property is being ignored. Try the following config instead:
src: ['**/*'],
expand: true,
cwd: 'app/img/',
dest: 'app/dist/img/'
The glob pattern *.* is probably not necessary as * will already match all files (unless you're specifically trying to match only files with a . in them.) Try using src: '*' to match all files within the single folder or src: '**/*' to match all files and folders within the cwd.
11.4k13535
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledgruntjs - How do we set a target in a grunt cssmin task? - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I am trying out
According to the docs targets can be defined "according to the grunt Configuring tasks guide."
When I create a cssmin task using that pattern, like:
my_target: {
src: 'path-to/default.css',
dest: 'path-to/default.min.css'
the minified file is not created.
If I remove the target level it works as expected.
Do I do something wrong here? or are there other options than cssmin (In my research I picked this as everybody was pointing to it)
grunt v0.4.1
cssmin v0.6.0
Thanks in advance,
Your configuration is just a little off. minify is also just a target name. Do this instead:
src: 'path-to/default.css',
dest: 'path-to/default.min.css'
my_target: {
src: 'path-to/default.css',
dest: 'path-to/default.min.css'
Please read
on how to configure tasks.
11.4k13535
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled  & 是一个基于任务的
项目命令行构建工具,运行于 Node.js 平台。Grunt 能够从模板快速创建项目,合并、压缩和校验 CSS & JS 文件,运行单元测试以及启动静态服务器。
安装 Grunt
  推荐 Windows 用户使用 Git Shell 来进行命令行操作。安装 Windows 桌面版 GitHub 的时候会自动安装 Git Shell。
  GitHub for Windows&下载地址:
  Grunt 运行于 Node.js 环境,这里假设你已经安装了 Node.js 和 NPM。
npm install grunt
  为了便于操作,可以使用参数 -g 配置为全局安装:
npm install -g grunt
创建项目框架
  安装好 Grunt 后就可以开始创建项目了,Grunt 内置下面四种基本的项目模板:
  gruntfile,创建命令:
grunt init:gruntfile
  commonjs,创建命令:
grunt init:commonjs
  jquery,创建命令:
grunt init:jquery
  node,创建命令:
grunt init:node
  我们今天创建的是 jQuery 项目,编写一个 jQuery 插件示例。现在 GitHub 创建好示例仓库 GruntDemo,然后使用桌面版工具克隆到本地,在 Git Shell 中进入仓库目录,再输入 grunt init:jquery 命令进行创建,如果当前位置已存在项目,可能会有如下提示:
  如果需要覆盖,这个时候需要使用 --forece 参数:
grunt init:jquery --force
  创建项目时,需要填写一些项目的基本信息,例如项目名称、描述、仓库地址、作者信息(后面几项有默认内容)等,如图示:
  OK,到这里项目就创建成功了!下面是项目的目录结构:
  并且&README.md 文件的内容和格式也生成好了:
  然后就可以编写插件代码了。Grunt 提供的 jQuery 插件代码框架如下:
* GruntDemo
* /bluesky/grunt-demo
* Copyright (c) 2013 BlueSky
* Licensed under the MIT license.
(function($) {
// Collection method.
$.fn.awesome = function() {
return this.each(function() {
$(this).html('awesome');
// Static method.
$.awesome = function() {
return 'awesome';
// Custom selector.
$.expr[':'].awesome = function(elem) {
return elem.textContent.indexOf('awesome') &= 0;
}(jQuery));
  同时还生成了相应的 Qunit 测试代码和页面:
/*global QUnit:false, module:false, test:false, asyncTest:false, expect:false*/
/*global start:false, stop:false ok:false, equal:false, notEqual:false, deepEqual:false*/
/*global notDeepEqual:false, strictEqual:false, notStrictEqual:false, raises:false*/
(function($) {
module('jQuery#awesome', {
setup: function() {
this.elems = $('#qunit-fixture').children();
test('is chainable', 1, function() {
// Not a bad test to run on collection methods.
strictEqual(this.elems.awesome(), this.elems, 'should be chaninable');
test('is awesome', 1, function() {
strictEqual(this.elems.awesome().text(), 'awesomeawesomeawesome', 'should be thoroughly awesome');
module('jQuery.awesome');
test('is awesome', 1, function() {
strictEqual($.awesome(), 'awesome', 'should be thoroughly awesome');
module(':awesome selector', {
setup: function() {
this.elems = $('#qunit-fixture').children();
test('is awesome', 1, function() {
// Use deepEqual & .get() when comparing jQuery objects.
deepEqual(this.elems.filter(':awesome').get(), this.elems.last().get(), 'knows awesome when it sees it');
}(jQuery));
  下篇预告:《JavaScript 项目构建工具 Grunt 实践:任务和指令》,敬请期待&&
您可能感兴趣的相关文章
本文链接:
编译来源:
阅读(...) 评论()}

我要回帖

更多关于 gulp grunt 比较 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信