0
votes

I've created an aurelia plugin (based on the skeleton-plugin) that consists of a custom element with a .js and .html file. I'm using this in another aurelia client application created using the aurelia cli. It gets installed with npm (from a local nexus repo). To get the client app to find the plugin, I had to add the following to the aurelia.json file

{
    "name": "@some-scope/some-plugin",
    "path": "../node_modules/@some-scope/some-plugin/dist/amd",
    "main": "some-plugin"
}

This works fine in dev, but the problem occurs when trying to build and run the production version from a server.

To build I run: au build --env prod this completes without error. Next I copy the scripts folder and index.html over to the server root. When I load the page that uses the plugin I get the following error in the dev tools of the browser

GET http://127.0.0.1:8080/node_modules/@some-scope/some-plugin/dist/amd/some-plugin.html 404 (Not Found)

Its trying to load the plugins html file from the node modules folder. What I would have expected is that the html required would have been bundled up into the bundled file vendor-bundle.js.

Am I missing something here?

1

1 Answers

0
votes

Aurelia cli only traces through the dependencies in your main file some-plugin.js.

This means all html/css files are not traced and bundled. Your additional js files could also be ignored if you did not explicitly import them in your main js file.

To be safe, when loading a plugin, tell cli to bundle all additional files.

{
    "name": "@some-scope/some-plugin",
    "path": "../node_modules/@some-scope/some-plugin/dist/amd",
    "main": "some-plugin",
    "resources": ["**/*.{js,html,css}"]
}