Skip to content

Empty resolve_with config array results in non-functional pipeline #519

Open
@kgreunke

Description

@kgreunke

At first glance this might be an obvious statement, however if you happen to end up with a config that falls through the below setup routine and ends up with an empty array, nothing works and nothing tells you why it's not working.

      if config.assets.resolve_with.nil?
        config.assets.resolve_with = []
        config.assets.resolve_with << :manifest if config.assets.digest && !config.assets.debug
        config.assets.resolve_with << :environment if config.assets.compile
      end

https://github.com/rails/sprockets-rails/blob/73e7351abff3506f6dca6b2da8abedfd5c7c0d77/lib/sprockets/railtie.rb#LL226C1-L230C10

I managed to hit this problem where someone set the assets debug flag in the initializer. When running in production mode the :manifest option gets kicked out because of the debug flag and the :environment option gets kicked out because the default option in rails is to not compile assets in production.

If :manifest and :environment are the only two available options for resolvers, and neither are picked up, something should throw a warning at some point that the pipeline isn't going to resolve any assets.

For search purposes this was causing ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.) based on whatever was the first pipeline asset to be rendered

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