我是gruntjs的新手,正在努力理解为什么简单的复制文件任务无法正常工作。下面是我在Gruntfile.js中的代码。
module.exports = function (grunt) {
"use strict";
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
// copy other css files
copy: {
dist: {
files: {
//expand: true, // required when using cwd
//cwd: ['.'], // set working folder / root to copy
src: './wwwroot/lib/html5-reset/assets/css/reset.css', // copy all files and subfolders
dest: './wwwroot/css/' // destination folder
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.registerTask("copyCss", ["copy"]);
};
执行任务时出现以下错误
正在加载“ Gruntfile.js”任务...确定+ copyCss运行任务:复制运行“复制”任务运行“ copy:dist”(复制)任务验证属性copy.dist是否存在于配置中...确定文件:./ wwwroot / lib / html5-reset / assets / css / reset.css-> src文件:./wwwroot/css/-> dest选项:encoding =“ utf8”,processContent = false,processContentExclude = [],timestamp = false,mode = false复制./wwwroot/lib/html5-reset/assets/css/reset.css-> src阅读./wwwroot/lib/html5-reset/assets/css/reset.css ...确定编写src ... ERROR警告:无法写入“ src”文件(错误代码:EISDIR)。使用--force,继续。完成,但有警告。进程以代码0终止。
感谢您对查明问题的帮助。
如下所示配置Gruntfile.js
。
这会将名为reset.css
的文件从wwwroot/lib/html5-reset/assets/css/
目录复制到wwwroot/css/
目录。
Gruntfile.js
module.exports = function (grunt) {
"use strict";
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
copy: {
dist: {
expand: true,
cwd: 'wwwroot/lib/html5-reset/assets/css',
src: 'reset.css',
dest: 'wwwroot/css'
}
}
});
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.registerTask("copyCss", ["copy"]);
};
示例之前:
.
├── Gruntfile.js
├── node_modules
│ └── ...
├── package.json
└── wwwroot
└── lib
└── html5-reset
└── assets
└── css
└── reset.css <--------------
以下示例:
.
├── Gruntfile.js
├── node_modules
│ └── ...
├── package.json
└── wwwroot
├── css
│ └── reset.css <--------------
└── lib
└── html5-reset
└── assets
└── css
└── reset.css <--------------