gruntjs的新手,目前正在使用它将一些npm发行版移动到public/js文件夹.
这是代码:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
bootstrapCss: {
src: "./node_modules/bootstrap/dist/css/bootstrap.css",
dest: "./public/css/bootstrap.css"
},
bootstrapTheme: {
src: "./node_modules/bootstrap/dist/css/bootstrap-theme.css",
dest: "./public/css/bootstrap-theme.css"
},
bootstrap: {
src: "./node_modules/bootstrap/dist/js/bootstrap.js",
dest: "./public/js/libs/bootstrap.js"
},
backbone: {
src: "./node_modules/backbone/backbone.js",
dest: "./public/js/libs/backbone.js"
},
backboneLocalstorage: {
src: "./node_modules/backbone.localstorage/backbone.localStorage.js",
dest: "./public/js/libs/backbone.localStorage.js"
},
requireJs: {
src: "./node_modules/requirejs/require.js",
dest: "./public/js/libs/requirejs.js"
},
underscore: {
src: "./node_modules/underscore/underscore.js",
dest: "./public/js/libs/underscore.js"
},
jquery: {
src: "./node_modules/jquery/dist/jquery.js",
dest: "./public/js/libs/jquery.js"
},
requireJsText: {
src: "./node_modules/requirejs-text/text.js",
dest: "./public/js/libs/requirejs-text.js"
}
}
});
// …Run Code Online (Sandbox Code Playgroud) 我Bower用来安装我的项目的依赖项,只获取我需要的文件Grunt.js,并将它们复制到static应用程序服务.
其中一个是MathJax库,但是当我尝试复制整个文件夹(参见下面的代码)时,它只是忽略了目录并将所有文件喷射到目标而不处理MathJax目录结构.
copy: {
MathJax: {
expand: true,
flatten: true,
cwd: 'bower_components/MathJax/',
src: ['**'],
dest: 'base/static/MathJax/'
}
}
Run Code Online (Sandbox Code Playgroud)
它是关于copy任务的常见错误Grunt还是我做错了什么?
我收到这个错误:
Warning: Unable to write file (Error code: EISDIR)
Run Code Online (Sandbox Code Playgroud)
我正在尝试复制目录中的所有文件和子文件夹.
当我省略**但以后没有复制我的文件时,以下工作.
任何想法如何解决错误?
copy: {
main: {
options: {
expand: true
},
files: [
{ src: 'public/static/**', dest: '../../../public/packages/xyz/hello'}
]
}
},
Run Code Online (Sandbox Code Playgroud) 我有一个大型目录结构,大多数应用程序的典型.
例如,像这样:
theprojectroot
|- src
| |- app
| | |- index.html
| | |- index.js
| | |- userhome
| | | |- userhome.html
| | | |- userhome.js
| | |- management
| | | |- management.html
| | | |- management.js
| | |- social
| | | |- social.html
| | | |- social.js
| |- assets
|- vendor
|- package.json
Run Code Online (Sandbox Code Playgroud)
我想将所有HTML目录中的所有文件 - 只有 HTML文件 - 复制到另一个文件夹中.
我目前正在使用Grunt copy复制所有文件,但现在我只想为HTML做这件事.在文档中,似乎没有选择文件类型的任何选项.
有没有人有他们可以建议这样做的黑客?
我想编写一个Grunt任务,在构建期间,将复制我拥有的所有.html文件,并在/ dist中创建它的.asp版本.
我一直在尝试使用grunt-contrib-copy来实现这一点,这就是我所拥有的:
copy: {
//some other tasks that work...
//copy an .asp version of all .html files
asp: {
files: [{
expand: true,
dot: true,
cwd: '<%= config.app %>',
src: ['{,*/}*.html'],
dest: '<%= config.dist %>',
option: {
process: function (content, srcpath) {
return srcpath.replace(".asp");
}
}
}]
} //end asp task
},
Run Code Online (Sandbox Code Playgroud)
我知道这个process功能实际上并不正确......我已经尝试了一些不同的正则表达式,使其工作无济于事.当我运行asp任务时,Grunt CLI说我已经复制了2个文件,但它们无处可寻.任何帮助表示赞赏.
我正在尝试grunt使用一个简单的任务grunt-contrib-copy,但它在到达复制任务时立即死亡,并显示以下消息:
运行"copy:main"(复制)任务
警告:EPERM,不允许操作'C:\ Documents and Settings'使用--force继续
因警告而中止
我在跑步:
C:\Documents and Settings不存在)C:\nodejs)我在两个C:\nodejs和我的项目文件夹(C:\Users\myusername\Documents\Programming\myprojectname没有空格或括号)中对"文档和设置"进行了全文搜索,但没有匹配.
我的copy任务定义是:
copy: {
main: {
files: [
{expand: true, cwd: 'src/core', src: '/**', dest: 'src/chrome/'},
{expand: true, cwd: 'src/core', src: '/**', dest: 'src/firefox/'}
]
}
},
Run Code Online (Sandbox Code Playgroud)
可能导致此错误的原因是什么?