gpt4 book ai didi

javascript - 如何从 Dojo 的构建系统中排除文件?

转载 作者:行者123 更新时间:2023-11-30 05:43:30 27 4
gpt4 key购买 nike

我正在关注 official documentation page about the topic但我无法将其配置为忽略 .txt 文件。

我的项目根目录下有一个 all.profile.js:

var profile = (function(){
return {
basePath: "./",
releaseDir: "../web",
action: "release",
layerOptimize: "closure",
optimize: "closure",
cssOptimize: "comments",
mini: true,
stripConsole: "all",

packages: [
{ name: "myapp", location: "myapp" }
]
};
})();

这是文件夹 myapp 中的 package.json:

{
"dojoBuild": "myapp.profile.js",
"name": "my-app",
"description": "This is My App",
"version": "1.0",
"main": "src"
}

这是 myapp.profile.js 也在文件夹 myapp 中:

var profile = (function(){
return {
// don't need to do anything on the 'test' folder so don't define it on the trees.
trees: [
["libs","libs",/txt$/], // ignore .txt files -> DOESN'T WORK!
["src","src",/txt$/] // ignore .txt files -> DOESN'T WORK!
],
resourceTags: {
test: function(filename, mid){
console.log("[test] filename: ",filename);
return filename.indexOf("test/") !== -1;
},
copyOnly: function(filename, mid){
//console.log("[copyOnly] mid: ",mid);
return false;
},
miniExclude: function (filename, mid) {
console.log("[miniExclude] filename: ",filename);
return mid in {
'myapp/myapp.profile': 1,
'myapp/package.json': 2
} || mid.indexOf(".txt") !== -1; // .txt are not ignored so exclude them...
},
amd: function(filename, mid) {
//console.log("[amd] mid: ",mid);
// myapp is not AMD but this will 'convert' it
return false;
}
}
};
})();

最后,这是文件夹结构:

web_dev/
-- myapp/
---- libs/
---- src/
---- test/
---- myapp.profile.js
---- package.json
-- all.profile.js

构建工具运行良好,它读取并处理所有文件,但 .txt 文件仍在发布目录中。

如果您发现我的逻辑或我如何配置构建系统有任何错误,请告诉我。我正在使用 Dojo 1.9.1。

提前致谢。

最佳答案

我不确定我的初始方案有什么问题,但这里是我为获得预期结果所做的更改:

  1. trees 声明从 myapp.profile.js 移动到all.profile.js 在“myapp”包定义中。
  2. 不指定树的根,而是检查一切并相应地排除:[".", ".",
    /(\/\.)|(~$)|(test|txt)/]

最后的all.profile.js:

var profile = {
basePath: "./",
releaseDir: "../web",
releaseName: "built",
action: "release",
layerOptimize: "closure",
optimize: "closure",
cssOptimize: "comments",
mini: true,
stripConsole: "all",

packages: [
{
name: "myapp",
location: "myapp",
trees: [
// don't bother with .hidden, tests and txt.
[".", ".", /(\/\.)|(~$)|(test|txt)/]
]
}
]
};

如果有人能准确指出我做错了什么,请分享。

关于javascript - 如何从 Dojo 的构建系统中排除文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19409720/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com