【问题标题】:Sencha 6 EXT JS Build using CMD - wrong pathsSencha 6 EXT JS Build 使用 CMD - 错误的路径
【发布时间】:2017-12-13 17:03:56
【问题描述】:

煎茶 6.2 CMD Sencha EXT JS GPL 6+ 我的网络结构[服务器端]

-/public_html/affiliates --/app/sprinkles/tracker/assets/sencha [工作区文件夹 - 在 /ext 中包含 ext] --/app/sprinkles/tracker/assets/sencha/affiliates - 包含 sencha 应用程序

来自 Web 端 [浏览器] 在http://localhost/affiliates 时调用应用程序 应用路径为http://localhost/assets-raw/tracker/assets/sencha/affiliates

注意:http://localhost/assets-raw/tracker/assets/sencha/affiliates/index.html 没问题!

当我转到http://localhost/affiliates 我收到 ext/classic 的 404 错误(可能 50ish js 无法加载) app/application.js 也无法加载

我需要能够将 ../assets-raw/tracker/assets/sencha/affiliates 添加到生产构建路径。

但是,我发现区分网络侧的路径以构建路径侧很困难。找不到可以讨论这个问题的 sencha 文档(我已经浏览了很多文档)

这是我的 app.json 配置 https://gist.github.com/bobby5892/bf607a37c79a62820cf7fcaa245553c4

workspace.json 配置 https://gist.github.com/bobby5892/689c54272ba49d63cb35b96f6a24266d

我如何在页面上初始化 extjs

  <script type="text/javascript">
        var Ext = Ext || {}; // Ext namespace won't be defined yet...

        // This function is called by the Microloader after it has performed basic
        // device detection. The results are provided in the "tags" object. You can
        // use these tags here or even add custom tags. These can be used by platform
        // filters in your manifest or by platformConfig expressions in your app.
        //
      Ext.manifest = '../assets-raw/tracker/assets/sencha/affiliates/classic';

    </script>

    <!-- The line below must be kept intact for Sencha Cmd to build your application -->
    <script id="microloader" data-app="48a1b848-93ab-47fe-ba5a-a54e94f92ae5" type="text/javascript" src="/assets-raw/tracker/assets/sencha/affiliates/bootstrap.js"></script>

如何编辑该路径?

这是 app.json 中的相关部分(包含在该要点中)

   "production": {
        "frameworks": {        
                "ext": {
                    "path":"../assets-raw/tracker/assets/sencha/ext",
                    "version":"6.2.0.981"
                }
            },
         "output": 
        {
                "base": "${workspace.build.dir}/${build.environment}/${app.name}",
                "page": "../assets-raw/tracker/assets/sencha/affiliates/index.html",
                "manifest": "../assets-raw/tracker/assets/sencha/affiliates/${build.id}.json",
                "js": "../assets-raw/tracker/assets/sencha/affiliates/${build.id}/app.js",
                "appCache": {
                    "enable": false
                },
                "resources": {
                    "path": "${build.id}/resources",
                    "shared": "resources"
                }
        },
        "loader": {
            "cache": "${build.timestamp}"
        },
        "cache": {
            "enable": false
        },
        "compressor": {
            "type": "yui"
        },
        "manifest": {
           "embed": true
        }

我也在通过 sencha cmd 进行构建

sencha app refresh
sencha app build

在此先感谢,已经花了很多时间来解决这个问题!

编辑:添加图像以显示路径与我需要的路径。

Paths

编辑:发现在sencha CMD生成构建时,classic.json中生成的路径是错误的。文档说更改“页面”的 app.json 中的输出参数可能有效。我在构建的“生产”部分中有它。还是行不通。 :(

【问题讨论】:

  • 很想在 sencha 论坛上发帖,因为这是那里讨论的后续,发帖被拒绝:/ 只是猜测:您是否将工作空间结构部署到您的实时系统上?在这种情况下,您只需构建(sencha app build)并使用与相对路径完美配合的输出。如果在开发中发生这种情况:更改 json 配置后你做了什么?你用sencha app watch吗?如果存在不正确的路径,这将自动重新生成所有需要的元数据并失败。是否有可能从您的文档根目录而不是此子文件夹提供应用程序?

标签: json extjs build


【解决方案1】:

在煎茶论坛上的讨论取得了成功。 https://www.sencha.com/forum/showthread.php?469231-Sencha-6-EXT-JS-Build-using-CMD-wrong-paths

通过在从 ajax 调用检索后但在 ExtJS 处理它们之前更改 Ext.Manifest 对象中的路径来解决。

  <script type="text/javascript">
    ExtAbsoluteBasePath = "/assets-raw/tracker/assets/sencha/build/production/affiliates/";
    var Ext = Ext || {}; // Ext namespace won't be defined yet...

    // This function is called by the Microloader after it has performed basic
    // device detection. The results are provided in the "tags" object. You can
    // use these tags here or even add custom tags. These can be used by platform
    // filters in your manifest or by platformConfig expressions in your app.
    //
    Ext.beforeLoad = function (tags) {
        var s = location.search,  // the query string (ex "?foo=1&bar")
            profile;

        // For testing look for "?classic" or "?modern" in the URL to override
        // device detection default.
        //
        if (s.match(/\bclassic\b/)) {
            profile = 'classic';
        }
        else if (s.match(/\bmodern\b/)) {
            profile = 'modern';
        }
        else {
            profile = tags.desktop ? 'classic' : 'modern';
            //profile = tags.phone ? 'modern' : 'classic';
        }

        Ext.manifest = ExtAbsoluteBasePath + profile; // this name must match a build profile name

        // This function is called once the manifest is available but before
        // any data is pulled from it.
        //
        return function (manifest) {
            // peek at / modify the manifest object

            console.log(manifest);
            // Update JS Paths
            var i=0;
            manifest.js.forEach(function(jsPath) {
                console.log("\n Updating JS Path - " + jsPath.assetConfig.path + " to " + ExtAbsoluteBasePath + jsPath.assetConfig.path);
                manifest.js[i].assetConfig.path = ExtAbsoluteBasePath + jsPath.assetConfig.path;
                i++;
            });

            // Update CSS Paths
            i=0;
            manifest.css.forEach(function(cssPath) {
                console.log("\n Updating CSS Path - " + cssPath.assetConfig.path + " to " + ExtAbsoluteBasePath + cssPath.assetConfig.path);
                manifest.css[i].assetConfig.path = ExtAbsoluteBasePath + cssPath.assetConfig.path;
                i++;
            });


            //manifest.js["0"].assetConfig.path = ExtAbsoluteBasePath + manifest.js["0"].assetConfig.path;
            console.log("\n JS Path - " + manifest.js["0"].assetConfig.path);
        };
    };
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多