在Cordova应用程序中使用Aurelia UX(无法为iOS构建)

时间:2017-12-30 22:32:36

标签: cordova requirejs aurelia aurelia-ux

我使用Aurelia CLI(v0.32, Typescript, Require.JS)+ Aurelia UX (v0.6.0)构建了一个Web应用程序。使用Brett Nelson tip,我正在为Cordova (v8.0.0)构建此网络应用。在浏览器平台(cordova run browser)中运行时一切正常但在运行IOS时失败(cordova run ios

这是错误:

enter image description here

我惊讶地发现只有Aurelia UX依赖项(core除外)无法加载。我怀疑require.js或依赖项名称中的@符号存在问题。

以下是我在aurelia.json

中声明依赖关系的方式
{
  "name": "@aurelia-ux/core",
  "path": "../node_modules/@aurelia-ux/core/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/button",
  "path": "../node_modules/@aurelia-ux/button/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/input",
  "path": "../node_modules/@aurelia-ux/input/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/icons",
  "path": "../node_modules/@aurelia-ux/icons/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/form",
  "path": "../node_modules/@aurelia-ux/form/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/checkbox",
  "path": "../node_modules/@aurelia-ux/checkbox/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/radio",
  "path": "../node_modules/@aurelia-ux/radio/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/datepicker",
  "path": "../node_modules/@aurelia-ux/datepicker/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/textarea",
  "path": "../node_modules/@aurelia-ux/textarea/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},
{
  "name": "@aurelia-ux/chip-input",
  "path": "../node_modules/@aurelia-ux/chip-input/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{css,html}"
  ]
},

然后我如何从main.ts文件中调用它们

aurelia.use
  .standardConfiguration()
  .plugin('aurelia-animator-css')
  .plugin('@aurelia-ux/core')
  .plugin('@aurelia-ux/form')
  .plugin('@aurelia-ux/button')
  .plugin('@aurelia-ux/input')
  .plugin('@aurelia-ux/icons')
  .plugin('@aurelia-ux/checkbox')
  .plugin('@aurelia-ux/radio')
  .plugin('@aurelia-ux/textarea')
  .plugin('@aurelia-ux/datepicker')
  .plugin('@aurelia-ux/chip-input')

如何避免Aurelia UX依赖性问题?

1 个答案:

答案 0 :(得分:0)

问题来自Bundle中包含的资源。为了使bundle在Cordova中正常工作,我们必须明确提及对每个插件中包含的所有JS文件的引用。 aurelia.json中每个插件的资源键必须如下所示:"resources": ["**/*.{js,css,html}"](带有 js,)部分。

最终aurelia.json档案:

{
  "name": "@aurelia-ux/core",
  "path": "../node_modules/@aurelia-ux/core/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/button",
  "path": "../node_modules/@aurelia-ux/button/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/input",
  "path": "../node_modules/@aurelia-ux/input/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/icons",
  "path": "../node_modules/@aurelia-ux/icons/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/form",
  "path": "../node_modules/@aurelia-ux/form/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/checkbox",
  "path": "../node_modules/@aurelia-ux/checkbox/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/radio",
  "path": "../node_modules/@aurelia-ux/radio/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/datepicker",
  "path": "../node_modules/@aurelia-ux/datepicker/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/textarea",
  "path": "../node_modules/@aurelia-ux/textarea/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},
{
  "name": "@aurelia-ux/chip-input",
  "path": "../node_modules/@aurelia-ux/chip-input/dist/amd",
  "main": "index",
  "resources": [
    "**/*.{js,css,html}"
  ]
},