【问题标题】:Is there a way to build a Dojo module that includes a single file from the package location?有没有办法构建一个包含来自包位置的单个文件的 Dojo 模块?
【发布时间】:2013-01-20 01:03:05
【问题描述】:

我有一个小型应用程序的以下构建配置文件:

var profile = (function(){

    var copyOnly = function(filename, mid){
        /* ..snip.. */
    };

    return {
        basePath: "../../src",
        releaseDir: "../dist",
        releaseName: "lib",
        action: "release",

        packages: [
        'dojo',
        'dijit',
        //'dojox',
        'amd',
        {
            name: 'lodash',
            location: 'lodash',
            trees: [
                [".", ".", /(\/\.)|(~$)|(vendor|test)/]
            ]
        },
        {
            name: 'd3',
            location: 'd3',
            main: 'd3.min',
            trees: [
                [".", ".", /(\/\.)|(~$)|(src|lib|test)/]
            ]
        },
        { name: 'app', location: 'app' }
    ],

        layers: {
            "dojo/dojo": {
                include: [ "dojo/dojo", "amd/d3","amd/gmaps",
                    "app/main", "app/run" ],
                customBase: true,
                boot: true
            }
        },

        resourceTags: {
            /* ..snip.. */
        }
    };
})();

问题是这样的:我所需要的只是要由 Dojo 构建系统处理的 lodash.min.js 文件。不幸的是,当您在配置文件中包含包定义时,构建系统会使用隐式 trees 值查看相关目录中的 all 文件。您可以覆盖它(就像我在这里所做的那样)并添加一些忽略指令,但这很丑陋,并且会让您遗漏一些东西。我喜欢要做的是明确指出我有兴趣为我的构建过程处理哪些文件。

Dojo 允许您这样做吗?这方面的文档有点少,但如果你能帮我找到更清楚地解释这一点的资源,那就太好了!

【问题讨论】:

    标签: javascript build dojo


    【解决方案1】:

    至少从 1.9 开始,我相信这是可以做到的:

    // ... snip ...
    {
        name:'lodash',
        location:'lodash',
        trees:[],
        dirs:[],
        files:[
            ["lodash.min.js"]
        ]
    },
    

    这会显式列出文件,同时还会压缩隐式树和目录发现。

    我的信念是基于对util/build/discover.js 的粗略审查——但当我阅读the documentation 文件时,只有应该得到支持。

    【讨论】:

      猜你喜欢
      • 2022-01-05
      • 2022-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-09
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      相关资源
      最近更新 更多