Closed ZephiroRB closed 3 years ago
In rails 6, you can still use app/assets/javascripts/application.js
//= require semantic-ui
or use with webpacker https://github.com/rails/webpacker#resolved, but i recommend to use yarn add semantic-ui
,
I am having the same problem:
yarn add semantic-ui
is not a good idea because it is not automated, this is asking for a Gulp prompt that will break the production deployment in the future.
//= require semantic-ui
raises the following error:
Uncaught ReferenceError: jQuery is not defined
Maybe this should be referenced in app/javascript/packs/application.js
in order to find JQuery. But how?
Can you help, please?
@jlebrijo You can try to put <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
before javascript_include_tag
.
Great point @doabit , thanks!
Finally I could integrate Rails 6 with this gem. Just sharing my complete solution.
We have JQuery as prerequisite: yarn add jquery popper.js
After that we have to create $ and jQuery handlers into webpack config, at packs/application.js
:
import JQuery from 'jquery';
window.$ = window.jQuery = JQuery;
Finally we have to import all files in the correct order at views/layouts/application.html.haml
:
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
Then we can do the usual imports. CSS at assets/stylesheets/application.scss
:
@import "semantic-ui";
And Javascripts at assets/javascripts/application.js
:
//= require semantic-ui
Hey @doabit, I believe the Javascript file has moved in rails 6 from app/assets/javascripts/application.js
to app/javascripts/packs/application.js
Edit: The above solution works for me - however it will require you to include the //= link application.js
in the app/assets/config/manifest.js
Related to this comment:
In rails 6, you can still use
app/assets/javascripts/application.js
//= require semantic-ui
or use with webpacker https://github.com/rails/webpacker#resolved, but i recommend to use
yarn add semantic-ui
,
How to include javascript in Rails 6?