Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Config assets added twice (once by ac.done and once by ac.assets) #1281

Open
aljimenez opened this issue Nov 4, 2013 · 3 comments
Open

Config assets added twice (once by ac.done and once by ac.assets) #1281

aljimenez opened this issue Nov 4, 2013 · 3 comments

Comments

@aljimenez
Copy link
Contributor

Assets in a mojit's config are added twice; once by the ac.done method and once by the ac.assets constructor method. When it is added by the ac.assets addon, assets with relative paths are expanded; however when added by ac.done, relative paths are not expanded resulting in a meta data with duplicate assets (one with a relative path and one with an absolute path). On the client side the absolute paths load; however the relative paths seem to be associated with the parent mojit resulting in 404s.

Resulting meta data:

{
    top: {
        css: [
            './index.css',
            '/static/Mojit/assets/index.css'
        ]
   }
}

assets.common.js:

// Add "assets" if they are found in the config.
if (command.instance && command.instance.config &&
        command.instance.config.assets) {
    this.addAssets(command.instance.config.assets);
}

action-context.common.js:

meta.assets = Y.mojito.util.metaMerge(meta.assets, config.assets || {});
@caridy
Copy link
Contributor

caridy commented Mar 3, 2014

@aljimenez did you ever solve this?

@aljimenez
Copy link
Contributor Author

From what I remember, my solution was not to use relative paths for assets in static configuration. But there is a problem since ac.done merges meta.assets with config.assets and then it calls ac.assets' mergeMetaInto method, which also merges assets contained in config.assets. So config.assets end up getting added twice. This becomes a problem when an asset is specified with a relative path, because ac.done simply does a metaMerge of config.assets without expanding the relative path.

@aljimenez
Copy link
Contributor Author

I guess there is a design flaw, since config.assets only need to be added in one place.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants