![](/img/trans.png)
[英]How to get Grunt-Contrib-Copy to copy files/directories relative to given source path
[英]Grunt source file relative path
為什么必須在源文件路徑中刪除前導斜杠,以便Grunt正確定位文件? gruntfile與包含JS文件的“ includes”文件夾一起存在於主項目中。
module.exports = function(grunt) {
var SiteMasterHeaderArray = [
"/includes/js/knockout/knockout-3.4.0.js",
"/includes/js/common/common.js"
];
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
dest: {
files: {
'dest/SiteMasterHeader.js': SiteMasterHeaderArray
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['uglify']);
};
未寫入目標文件,因為(至少對我來說是這樣),由於文件路徑中的“ /”,Grunt正在其他位置搜索這些文件。 刪除斜杠,該功能將完美運行。
前導/
表示這是一個絕對路徑,它正在從根目錄開始尋找它。 否則,它將從Gruntfile.js
所在的位置搜索相對路徑。
如果您希望路徑相對於Gruntfile
以外的其他文件夾,請參閱grunt.file.setBase
或--base
cli選項。 更多信息在這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.