Skip to content

fix AssetAliasUsed issue #257

Closed
Closed
@rmosolgo

Description

@rmosolgo

In react-rails, we add different paths to the asset pipeline based on the app's config. With Sprockets 2 + sprockets-rails 2.3.1, this causes AssetAliasUsed error.

Is this error actually a problem? If not, it would be nice to remove it (or fix the check so it isn't raised in this case) and ship 2.3.2. If it is a problem, what does it mean? Or how should I fix it?

See full conversation, here's my initial report copied from that thread:

react-rails setup

In react-rails, app config specifies either production or development, based on that, we add a path to app.config.assets.paths, roughly speaking:

# add directory to asset pipeline, 
# based on the app config
app.config.assets.paths << root_path.join('lib/assets/react-source/').join(directory).to_s

(full src)

We do this so that the app only needs //= react, then, each environment gets its version of React.js (the development version has nice error messages, the production version has none).

error

However, we get an AssetAliasUsed from the javascript_include_tag helper:

image

Sure enough, these don't match:

image

Interestingly, if I upgrade to Sprockets 3 + sprockets-rails 2.3.1, I don't get this error (which is fine for me, but not fine for many other react-rails users...).

Is this the expected outcome? Are we misusing the asset pipeline? Anything else I can do to diagnose or address this?

We're really hoping to support an API where //= require react can provide different versions of the file based on environment configs. Previously we copied JS files into local directories, but that had its own issues!

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions