[英]Sencha 6 EXT JS Build using CMD - wrong paths
Sencha 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
在此先感谢您,花了很多时间来解决这个问题!
编辑:添加图像以显示相对于我需要的路径。
编辑:发现当sencha CMD生成内部版本时,classic.json中的生成路径是错误的。 该文档说,更改app.json中“页面”的输出参数可能有效。 我在构建的“生产”部分中提到了这一点。 还是行不通。 :(
sencha论坛上的讨论结果取得了成功。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.