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

前端 未结 4 1871
别跟我提以往
别跟我提以往 2020-12-18 12:09

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 applic

4条回答
  •  鱼传尺愫
    2020-12-18 13:09

    Check the directory names to make sure they aren't conflicting with Webpacker's output. In my case, Rails was unable to find application.css even though Webpacker had successfully compiled it.

    // Webpacker log output
    Asset                         Size       Chunks       Chunk Names
    application.js                3.62 MiB   application  [emitted]              application
    css/application-631a168a.css  332 KiB    application  [emitted] [immutable]  application
    

    My relevant directory structure:

    app/javascript
    |——packs
    |  └——application.js
    └——src
       └——assets
          |——css
          └——scss
             └——application.scss
    

    In my case, the problem was that I already had a directory named css, so when Rails went to look for the compiled css/application.css, it went to this directory instead of the one generated by Webpacker and wasn't able to find application.css.

    Deleting the conflicting directory fixed it:

    $ rm -rf app/javascript/src/css // change path appropriately
    

提交回复
热议问题