Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpacker throws application.css not found in manifest.json in *Rails 6* application

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';

enter image description here

like image 575
Siva Ganesh Avatar asked Oct 22 '19 14:10

Siva Ganesh


1 Answers

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

like image 133
Siva Ganesh Avatar answered Nov 15 '22 06:11

Siva Ganesh