Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turbolinks config requires turbolinks.js be precompiled #172

Open
ryanb opened this issue Mar 11, 2020 · 2 comments
Open

Turbolinks config requires turbolinks.js be precompiled #172

ryanb opened this issue Mar 11, 2020 · 2 comments
Labels

Comments

@ryanb
Copy link

ryanb commented Mar 11, 2020

Enabling the turbolinks config causes this error:

Sprockets::Rails::Helper::AssetNotPrecompiled - Asset was not declared to be precompiled in production.
Add `Rails.application.config.assets.precompile += %w( turbolinks.js )` to `config/initializers/assets.rb` and restart your server

This is because turbolinks.js is included as a separate script in the HTML when this config is enabled.

I thinks it's better for turbolinks to be included in application.js so it's managed by sprockets and not a separately loaded JS file. Then you could remove this turbolinks config and add documentation for enabling it by overriding application.js

@tian-im tian-im added the wip label May 20, 2020
@tian-im
Copy link
Collaborator

tian-im commented May 20, 2020

Yeah, that's one way to do it. And I'm thinking to use a different way, for example:

<%= javascript_include_tag 'turbolinks', 'data-turbolinks-track' => true, 'data-turbolinks-eval' => false if Rails.application.config.assets.precompile.include?('turbolinks.js') %>

Then once turbolinks is added to precompile assets, Wallaby will include it as well.

@tian-im
Copy link
Collaborator

tian-im commented May 21, 2020

But yeah, maybe leave it to the user is the right way to go.

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

No branches or pull requests

2 participants