如何从Dojo的Build System中排除文件? [英] How to exclude files from Dojo's Build System?

查看:137
本文介绍了如何从Dojo的Build System中排除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注官方文档页面关于主题,但我无法将其配置为忽略 .txt 文件。

I'm following the official documentation page about the topic but I cannot configure it to ignore .txt files.

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

I have a all.profile.js on the root of my project:

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

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

这是$ code> package.json 里面文件夹 myapp

And this is the package.json inside the folder myapp:

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

这是code> myapp.profile.js 也位于文件夹 myapp 之内:

And this is the myapp.profile.js also inside the folder 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;
            }
        }
    };
})();

最后,这是文件夹结构:

Finally, this is the folder structure:

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

构建工具运行正常,它读取和处理所有文件,但$ code> .txt 文件仍在发布dir。

The build tool runs fine, it reads and process all files but the .txt files are still on the release dir.

如果您发现我的逻辑错误或配置构建系统,请让我知道。我正在使用Dojo 1.9.1。

Please let me know if you spot any mistakes on my logic or how I'm configuring the build system. I'm using Dojo 1.9.1.

提前感谢

推荐答案

我不知道我的初始场景有什么问题,但这里是我做出的所有改变:

I'm not sure what is wrong with my initial scenario but here are the changes that I made to have the desired result:


  1. tree 声明从 myapp.profile.js 移到
    全部

  2. 不要指定树的根,而是检查
    所有内容并相应排除:
  3. code> [。,。,
    /(\/\.)|(~$)|(test|txt)/]
  1. Move the trees declaration from the myapp.profile.js to all.profile.js inside the 'myapp' package definition.
  2. Instead of specifying the root of the trees, check everything and exclude accordingly: [".", ".", /(\/\.)|(~$)|(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)/]
            ]
        }
    ]
};

如果有人可以确切指出我在做错什么,请分享。

If anyone can pin point exactly what I was doing wrong, please share.

这篇关于如何从Dojo的Build System中排除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆