3

I have a Rails 5 app using the webpacker gem. I would like to access the image urls with the hash from the rails asset compilation appended to the end of their file names.

here is my /config/webpacker.yml file

# Note: You must restart bin/webpack-dev-server for changes to take effect

default: &default
  source_path: app/javascript
  source_entry_path: packs
  public_output_path: packs
  resolved_paths: ['app/assets/images']

  extensions:
    - .coffee
    - .erb
    - .js
    - .jsx
    - .ts
    - .vue
    - .sass
    - .scss
    - .css
    - .png
    - .svg
    - .gif
    - .jpeg
    - .jpg

development:
  <<: *default

  dev_server:
    host: 0.0.0.0
    port: 8080
    https: false

test:
  <<: *default

  public_output_path: packs-test

production:
  <<: *default

And I am attempting to import an image via import logo from '../logo.jpg';

I receive this error:

Module not found: Error: Can't resolve '../logo.jpg' in '/Users/macusername/Documents/work/railsapp/app/javascript/components'

wuliwong
  • 4,238
  • 9
  • 41
  • 69

0 Answers0