我在运行 grunt 复制任务时遇到问题。我在 package.json 中的依赖项下指定了一个库,如下所示
"@tarekraafat/autocomplete.js": "^7.2.0"
并在 Gruntfile.js 中声明复制任务如下
var paths = {
webroot: "wwwroot/"
};
// destination css path
paths.cssOutput = paths.webroot + "css";
// where to find bower resources
paths.bower_components = paths.webroot + "lib";
// where to find reset.css
paths.resetCss = paths.bower_components + "/html5-reset/assets/css";
module.exports = function (grunt) {
"use strict";
// Project configuration
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: [paths.cssOutput, paths.bower_components],
// copy other css files
copy: {
options: {
'-W069': false,
'reporterOutput': "",
'esnext': true
},
dist: {
expand: true, // required when using cwd
cwd: paths.resetCss, // set working folder / root to copy
src: ['reset.css'], // copy all files and subfolders
dest: paths.cssOutput //'./wwwroot/css/' // destination folder
},
autoCompleteJS: {
expand: true,
cwd: "wwwroot/lib/@tarekraafat/autocomplete.js/dist/js",
src: ['autoComplete.min.js'],
dest: ['wwwroot/js']
},
autoCompleteCSS: {
expand: true,
cwd: "wwwroot/lib/@tarekraafat/autocomplete.js/dist/css",
src: ['autoComplete.css'],
dest: ['wwwroot/css']
}
}
});
// Load the plugin
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('downloadPkgs', ['pkg']);
grunt.registerTask('cleanAll', ['clean']);
grunt.registerTask('copyAll', ['copy']);
};
单独运行任务“copy:autoCompleteJS”或“copy:autoCompleteCSS”时,我收到以下警告
运行任务:copy:autoCompleteCSS
运行“copy:autoCompleteCSS”(复制)任务
验证属性 copy.autoCompleteCSS 存在于配置中...OK
警告:“路径”参数必须是字符串类型。接收到的类型对象使用 --force 继续。
由于警告而中止。
进程以代码 3 终止。
注意:如果我运行任务“copy:dist”,它工作正常。我怀疑在其他两个中提供给 cwd 的路径在目录名称中有特殊字符“@”导致了问题。
感谢您的帮助。
MSRS。