Closed
Description
Hello,
We are following every RC update so today I upgraded from rc5 to rc7 and I noticed that all my images now need to be references differently. To get started some configuration files:
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: false
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: ['app/javascript/src']
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract CSS files
extract_css: true
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .mjs
- .jsx
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
- .graphql
development:
<<: *default
compile: true
check_yarn_integrity: true
In our main application.js
file we require the images (else they would never be included in the pack)
import 'bootstrap'
// Start Rails UJS
import Rails from 'rails-ujs'
Rails.start()
// Require images
require.context('../images/', true, /\.(gif|jpg|png|svg|ico)$/i)
Our environment.js
didn't change, we do add the sass resolve-url-loader
environment.loaders.get('sass').use.splice(-1, 0, {
loader: 'resolve-url-loader'
})
For example the favicon in RC5 could be referenced as:
<link rel="shortcut icon" href="<%= asset_pack_path('images/favicon.ico') %>" data-environment="<%= Rails.env %>">
But in RC7 this needs to be
<link rel="shortcut icon" href="<%= asset_pack_path('media/favicon.ico') %>" data-environment="<%= Rails.env %>">
Even more problematic are subdirectories in the images (for example app/javascript/images/logo/brand-color.png
), in RC5
<%= image_pack_tag('images/logo/brand-color.png', class: 'd-inline-block align-top') %>
In RC7 this got changed again to media but it also removed the subdir
<%= image_pack_tag('media/brand-color.png', class: 'd-inline-block align-top') %>
So I'm wondering how I should reference images correctly and if that subdirectory is not a bug or something.
Regards
Metadata
Metadata
Assignees
Labels
No labels