How to deliver an aurelia library for consumption by aurelia CLI based app

时间:2016-08-31 17:42:56

标签: aurelia aurelia-cli

I'm building a library of aurelia custom elements for use by several different aurelia apps and am running into trouble getting the custom element html hooked into the app bundle properly with the CLI process.

I'm currently thinking that the library will be part of package.json and thus listed under node_modules/my-lib. What should the delivered .html format be

<template>...</template> 

or should it be delivered in required format

define('text!my-lib/component1.html', ['module'], function(module) { module.exports = "<template>\r\n  ...

If the former - what do I put in aurelia.json to get it to be included correctly in the vendor-bundle?

If I do resouces['../node_modules/my-lib/**/*.html'] in my-lib dependency section - it gets included as html in a js file which throws an error.

If I add as source to the vendor-bundle or using my own bundle my-lib-bundle.js

"source": [
    "[../node_modules/my-lib/**/*.js]",
    "../node_modules/my-lib/**/*.{css,html}"
],

Nothing gets included then except the 'main' listed in the one dependency.

If I add to the markupProcess (which seems more linked to the app and not a library)

"markupProcessor": {
    "id": "none",
    "displayName": "None",
    "fileExtension": ".html",
    "source": [
        "src\\**\\*.html",
        "..\\node_modules\\my-lib\\**\\*.html"
    ]
},

I get the html correctly added to app-bundle but has the wrong path because it includes the '../node_modules' in the define so it's not found when the app attempt to use it.

I'm not using the CLI to build my lib as I want the app to only include pieces it uses. So the JS is built and delivered in AMD format, but I wasn't sure the process to go through with HTML?

Suggestions?

1 个答案:

答案 0 :(得分:0)

有一个骨架插件repo @ github https://github.com/aurelia/skeleton-plugin

使用构建脚本和所有