Dojo的自定义生成器得到的错误,由于缺少资源 [英] Dojo custom build getting browser errors due to missing resources

查看:306
本文介绍了Dojo的自定义生成器得到的错误,由于缺少资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在挣扎学习基于AMD Dojo构建系统。到目前为止,我还没有能够得到一个版本是可用的没有得到在浏览器(FF)加载错误。

我对如何管理构建的问题。

我的生成配置文件有一个包款。我指定似乎有直接关联的那些相同的包目录被写入到目标目录中。这似乎是适当的。不过,我也有尝试,当他们合并成一个文件的dojo.js合并只是引用,从道场,dijit中,DojoX中,等模块层部分,我还有所有那些库目录在我的目的地目录。它是了解,你只是手动去并删除它们还是有一个自动的方式,让他们在生成过程中删除?

在我的第一层我尝试建立它道场,dijit的和DojoX中/应用/主。这不拉过任何资源,如道场/资源/ blank.gif或在同一目录中的任何.css文件。怎样才能得到这些资源文件到复制到目标?我相信dojo.profile.js(它确实表明复制的资源)只影响道场目录。但自从我创建一个定制的Dojo /的dijit / DojoX中,结合JS模块文件,也没有资源目录。自定义生成后,我应该手动进入道场目录和移动道场/资源目录了,但折腾道场目录的休息吗?只是不知道如何让在道场DIR与自定义的dojo.js当道场/ dijit的层建立图层文件使用访问的依赖IMG和CSS文件。

下面是我的生成配置文件:

无功配置= {
    基本路径:./,
    // RELEASEDIR:IRB释放
    动作:释放,
    cssOptimize:评论,
    stripConsole:'所有',
    selectorEngine:'极致',
    layerOptimize:'关闭',
    优化:'关闭',
    微型:真实,
    包:
            {名:道场,地点:../libs/dojo},
            {名:dijit的位置../libs/dijit},
            {名:DojoX中,地点:../libs/dojox},
            {名:dgrid的位置:../libs/dgrid},
            {名字:把选择器的位置:../libs/put-selector},
            {名:xstyle的位置:../libs/xstyle},
            {名:MYPKG的位置:../libs/myPkg},
            {名:IRB的位置:../irb}
    ]
    层:{
            发布/ IRB /库/道场:{
                    包括:道场/道场,的dijit / dijit的,DojoX中/应用/主],
                    启动:真实,
                    customBase:真
            },
            发布/ IRB /库/ MYPKG:{
                    包括:
                            MYPKG /对话框/ MessageBox的
                            MYPKG /格/ FilterGrid
                            MYPKG / UTIL / WidgetMonitor
                            MYPKG /控制器/ BorderLayout的
                            MYPKG /控制器/ UnloadViewController
                     ]
                    includeLocales:EN-US]
            },
            发布/ IRB /库/存储/内存:{
                    包括:道场/存储/内存]
            },
            发布/ IRB /库/存储/可观察:{
                    包括:道场/存储/观测]
            },
            IRB / IRB:{
                    包括:
                            IRB / IRB
                            DojoX中/应用/视图
                            DojoX中/ CSS3 /过境,
                            DojoX中/应用/控制器/加载,
                            DojoX中/应用/控制器/过渡,
                            DojoX中/应用/控制器/历史
                    ]
            }
    },    staticHasFeatures:{
            //跟踪和放大器;登录API是用于调试装载机,所以我们并不需要他们在构建。
            道场踪-API:0,
            道场-LOG-API:0,            //这将导致暴露调试正常私有装载机的数据。在发布版本,我们并不需要
            //要么。
            道场 - 发布 - 士兵:0,            //这个应用程序是纯AMD,因此摆脱了传统的装载机。
            道场同步加载器':0,            //`Dojo的XHR-factory`依赖于`道场同步-loader`,我们已经删除。
            Dojo的XHR-工厂:0,            //我们不加载在生产测试,所以我们可以摆脱一些测试嗅探code的。
            道场 - 测试 - 嗅':0
    }
};

更新:这里是我的目录结构,这是约。基于对DojoX中/应用程序结构:

  /(根目录)
    / IRB
        /控制器
        / RES
            / CSS
            / IMG
        /人次
        build.sh
        config.json
        的index.html
        irb.js
        package.js
        的package.json
        release.profile.js
    /库
        / dgrid
        /的dijit
        /道场
        / DojoX中
        / MYPKG
        /把选择器
        / UTIL
        / xstyle

有关构建我使用基于DojoX中/应用的例子,但它会调用内部命令行是build.sh文件:

 节点/家庭/(用户)/(项目...路径)/(根目录)/libs/dojo/dojo.sh
  负载=构建
  --require/家庭/(用户)/(项目...路径)/(根目录)/irb/irb.js
  --profile/家庭/(用户)/(项目...路径)/(根目录)/irb/release.profile.js
  --appConfigFile/家庭/(用户)/(项目...路径)/(根目录)/irb/config.json
  --releaseDir/家庭/(用户)/(项目...路径)/(根目录)/建


解决方案

额外的文件和目录

我认为这是一个很好的做法,不能删除它们。之所以进行构建是通过结合使用到几个(preferably一个)JavaScript文件的一切,以提高网页浏览器的性能。

但是,如果是,用于一个文件(模块)不是以层包括会发生什么。如果你在构建目录中的其他文件,应用程序仍然可以工作,你只需要在服务器的额外调用来获取该文件。如果你已经删除了这些目录和文件,应用程序将中断。


拉动对资源

做一个自定义生成之后,我有一个

 发布/ RELEASE_NAME /道场/资源

目录,其中包含你所提到的。

的所有资源

编辑:添加例子...

示例

命令

 节点路径/到/道场/的dojo.js
    负载=建立--profile路径/要/ build.profile.js --release --version = 1.9.0

build.profile.js

  VAR配置=(函数(){
    返回{
        //假设节点命令正在被运行
        // Web根目录的目录。如果不是,更新基本路径
        //使用当前目录作为libs目录
        //起点。
        基本路径:./libs        RELEASEDIR:/路径/要/发行/目录,
        动作:释放,
        releaseName:释放,
        layerOptimize:ShrinkSafe的
        优化:假的,
        cssOptimize:评论,
        微型:假的,
        stripConsole:正常,
        selectorEngine:极致,        包:
            {名称:'道场',位置:道场},
            {名称:'dijit的',位置:dijit的},
            {名称:'DojoX中,地点:DojoX中},
            {名称:'dgrid',位置:dgrid},
            {名称:'把选择器,定位:把选择器},
            {名称:'xstyle',位置:xstyle'}
            {名称:'IRB',位置:../irb},
        ]
        层:{
            IRB /道场:{
                包括:道场/道场,的dijit / dijit的,DojoX中/应用/主],
                启动:真实,
                customBase:真
            },
            ...
        }
    };
})();

I've been struggling with learning the AMD based Dojo build system. So far I haven't been able to get a build that is usable without getting load errors in the browser (FF).

I have questions about how to manage the build.

My build profile file has a packages section. What I specify there seems to directly correlate to those same package directories being written into the destination directory. This seems appropriate. However, I also have a layers section that is trying to merge just the "referenced" modules from dojo, dijit, dojox, etc. When they get combined into one dojo.js file, I still have all those library directories in my destination dir. Is it understood that you just manually go in and remove them or is there an automatic way to get them removed during the build?

In my first layer I try to build it for dojo, dijit and dojox/app/main. This is not pulling over any resources, such as dojo/resources/blank.gif or any .css files in that same directory. How does one get those resource files to copy over to the destination? I believe dojo.profile.js (which does indicate to copy those resources) only impacts the dojo directory. But since I am creating a custom dojo/dijit/dojox file that combines js modules, there is no resources directory. After the custom build, am I supposed to manually go into the dojo directory and move the dojo/resources dir out but toss the rest of the dojo dir? Just not sure how to get the dependent img and css files accessible in the dojo dir for use with the custom dojo.js layer file when a dojo/dijit layer is built.

Here's my build profile:

var profile = {
    basePath: "./",
    //releaseDir: "irb-release",
    action: "release",
    cssOptimize: "comments",
    stripConsole: 'all',
    selectorEngine: 'acme',
    layerOptimize: 'closure',
    optimize: 'closure',
    mini: true,
    packages:[
            { name: "dojo",         location: "../libs/dojo" },
            { name: "dijit",        location: "../libs/dijit" },
            { name: "dojox",        location: "../libs/dojox" },
            { name: "dgrid",        location: "../libs/dgrid" },
            { name: "put-selector", location: "../libs/put-selector" },
            { name: "xstyle",       location: "../libs/xstyle" },
            { name: "myPkg",     location: "../libs/myPkg" },
            { name: "irb",          location: "../irb" }
    ],
    layers: {
            "release/irb/libs/dojo": {
                    include: ["dojo/dojo", "dijit/dijit", "dojox/app/main"],
                    boot: true,
                    customBase: true
            },
            "release/irb/libs/myPkg": {
                    include: [
                            "myPkg/dialog/MessageBox",
                            "myPkg/grids/FilterGrid",
                            "myPkg/util/WidgetMonitor",
                            "myPkg/controllers/BorderLayout",
                            "myPkg/controllers/UnloadViewController"
                     ],
                    includeLocales: [ 'en-us' ]
            },
            "release/irb/libs/store/Memory": {
                    include: [ "dojo/store/Memory" ]
            },
            "release/irb/libs/store/Observable": {
                    include: [ "dojo/store/Observable" ]
            },
            "irb/irb": {
                    include: [
                            "irb/irb",
                            "dojox/app/View",
                            "dojox/css3/transit",
                            "dojox/app/controllers/Load",
                            "dojox/app/controllers/Transition",
                            "dojox/app/controllers/History"
                    ]
            }
    },

    staticHasFeatures: {
            // The trace & log APIs are used for debugging the loader, so we do not need them in the build.
            'dojo-trace-api': 0,
            'dojo-log-api': 0,

            // This causes normally private loader data to be exposed for debugging. In a release build, we do not need
            // that either.
            'dojo-publish-privates': 0,

            // This application is pure AMD, so get rid of the legacy loader.
            'dojo-sync-loader': 0,

            // `dojo-xhr-factory` relies on `dojo-sync-loader`, which we have removed.
            'dojo-xhr-factory': 0,

            // We are not loading tests in production, so we can get rid of some test sniffing code.
            'dojo-test-sniff': 0
    }
}; 

UPDATE: Here is my directory structure which is approx. based on the dojox/app structure:

/(webroot)
    /irb
        /controllers
        /res
            /css
            /img
        /views
        build.sh
        config.json
        index.html
        irb.js
        package.js
        package.json
        release.profile.js
    /libs
        /dgrid
        /dijit
        /dojo
        /dojox
        /myPkg
        /put-selector
        /util
        /xstyle

For the build i use the build.sh file based on dojox/app example but the internal command line it calls is:

node "/home/(user)/(project ... path)/(webroot)/libs/dojo/dojo.sh" 
  load=build 
  --require "/home/(user)/(project ... path)/(webroot)/irb/irb.js" 
  --profile "/home/(user)/(project ... path)/(webroot)/irb/release.profile.js"
  --appConfigFile "/home/(user)/(project ... path)/(webroot)/irb/config.json"
  --releaseDir "/home/(user)/(project ... path)/(webroot)/build" 

解决方案

Extra files and directories

I think it is a good practice to not remove them. The reason for performing a build is to improve web browser performance by combining everything that is used into a few (preferably one) javascript file.

But what happens if a file(module) that is used is not included in a layer. If you have the other files in the build directory, the application will still work, you will just have an additional call to the server to get that file. If you have removed these directories and files, your application will break.


Pulling over resources

After doing a custom build, I have a

release/RELEASE_NAME/dojo/resources 

directory, which contains all the resources you mentioned.


EDIT: Adding example...

Example

Command

node path/to/dojo/dojo.js 
    load=build --profile path/to/build.profile.js --release --version=1.9.0

build.profile.js

var profile = (function(){
    return {
        // Assuming that the node command is being run in 
        // the webroot directory.  If not, update the basePath
        // to the libs directory using the current directory as
        // the starting point.
        basePath:        "./libs",

        releaseDir:      "/path/to/release/dir",
        action:          "release",
        releaseName:     "release",
        layerOptimize:   "shrinksafe",
        optimize:        false,
        cssOptimize:     "comments",
        mini:            false,
        stripConsole:    "normal",
        selectorEngine:  "acme",

        packages:[
            {name: 'dojo', location: 'dojo'},
            {name: 'dijit', location: 'dijit'},
            {name: 'dojox', location: 'dojox'},
            {name: 'dgrid', location: 'dgrid'},
            {name: 'put-selector', location: 'put-selector'},
            {name: 'xstyle', location: 'xstyle'}
            {name: 'irb', location: '../irb'},
        ],
        layers: {
            'irb/dojo": {
                include: ["dojo/dojo", "dijit/dijit", "dojox/app/main"],
                boot: true,
                customBase: true
            },
            ...
        }
    };
})();

这篇关于Dojo的自定义生成器得到的错误,由于缺少资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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