usabilityhub/rails-erb-loader

Using with Shakapacker

Closed this issue · 1 comments

I'd like to use this gem. Any got it working with Shakapacker?

Unfortunately adding the installation instructions doesn't work.

I've renamed the file:

app/client/src/constants/proposalStatuses.js.erb

But I get:

Module not found: Error: Can't resolve './proposalStatuses' in '/Users/amirsharif/Projects/halo/app/client/src/constants'
 @ ./app/client/src/App.jsx 16:0-80 70:27-63 327:17-53 334:8-39 858:11-23 860:5-22 862:16-32
 @ ./app/client/packs/app.tsx 16:0-29 67:24-27

I managed to fix this by referencing the .erb part directly and adding the resolve statement in my config.

  • Update this line to include .erb in the Webpacker config:
    extensions: [".scss", ".css", ".ts", ".tsx", ".png", ".erb"],
  • Change your imports to the following:
    import PROPOSAL_STATUSES, { PROPOSAL_STATUS_TO_TAB } from "./proposalStatuses.js.erb";