Currently we use Rails 6 for our application. It's working fine in production but in development mode it throws some errors. Please assist me.
This is how my application.js and application.css looks like
packs/application.js
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("jquery")
import '../stylesheets/application'
import './bootstrap_custom.js'
import './side_menu.js.erb'
//import './sweetalert.js'
import './business_hours.js'
import './admin.js'
import './services.js'
import './user_service.js'
Packs/stylesheets/application.scss
@import './bootstrap_custom.scss';
$fa-font-path: '~@fortawesome/fontawesome-free/webfonts';
@import '~@fortawesome/fontawesome-free/scss/fontawesome';
@import '~@fortawesome/fontawesome-free/scss/solid';
@import './admin_dashboard.scss';
@import './side_menu.css';
@import './fonts.scss';
@import './login.css';
After a long struggle I found a solution for this. Thanks @ahmed kamal.
Multiple packs with the same name but a different extension.
i.e: application.scss and application.js only the last one will make it to the webpack entry path configuration.
Solution:
1. Rename stylesheets/application.scss into stylesheets/style.scss
2. Import style.scss in application.js like this import '../stylesheets/style'
3. config/webpacker.yml make below changes
compile: true
cache_manifest: true
extract_css: true
If this solution not working for you, try th
rake assets:precompile
Thats all its started working fine for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With