Move most images to asset pipeline

Webpacker still needs to know about them in order to build links.
This commit is contained in:
David Cook
2023-04-13 16:02:25 +10:00
parent b217e9da96
commit 177445521c
28 changed files with 39 additions and 47 deletions

View File

@@ -1,6 +1,6 @@
%fieldset.no-border-top
.add_producer_properties
= image_pack_tag 'spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator'
= image_tag 'spinner.gif', :plugin => 'spree', :style => 'display:none;', :id => 'busy_indicator'
%table.index.sortable{"data-sortable-link" => main_app.update_positions_admin_enterprise_producer_properties_url(@enterprise)}
%thead
%tr

View File

@@ -1,2 +1,2 @@
= cache do
%img.spinner{ src: image_pack_path("spinning-circles.svg"), style: "max-width: 100%" }
%img.spinner{ src: image_path("spinning-circles.svg"), style: "max-width: 100%" }

View File

@@ -3,7 +3,7 @@
.row
.small-12.text-center.columns
%h1
%img{src: image_pack_path("logo-white-notext.png"), title: Spree::Config.site_name}
%img{src: image_path("logo-white-notext.png"), title: Spree::Config.site_name}
%br/
%a.button.transparent{href: "/shops"}
= t :home_shop

View File

@@ -20,7 +20,7 @@
= csrf_meta_tags
%body.off-canvas{ style: "background-image: url(#{image_pack_path('tile-wide.png')})", "data-turbo": "false" }
%body.off-canvas{ style: "background-image: url(#{image_path('tile-wide.png')})", "data-turbo": "false" }
.off-canvas-wrap{offcanvas: true}
.inner-wrap

View File

@@ -41,7 +41,7 @@
%p.word-wrap{"ng-if" => "::producer.whatsapp_phone"}
%a{"ng-href" => "{{::producer.whatsapp_url}}", target: "_blank"}
%img{ src: image_pack_path("social-logos/whatsapp.svg") }
%img{ src: image_path("social-logos/whatsapp.svg") }
%span{"ng-bind" => "::producer.whatsapp_phone"}
%p.word-wrap{"ng-if" => "::producer.email_address"}

View File

@@ -6,7 +6,7 @@
%h4= t(".message")
.row
.small-12.medium-3.large-2.columns.text-right.hide-for-small-only
%img{:src => image_pack_path("potatoes.png") }
%img{:src => image_path("potatoes.png") }
.small-12.medium-9.large-10.columns
%p
= t(".text")

View File

@@ -4,7 +4,7 @@
.row
.small-12.columns.text-center
.logo
%img{src: image_pack_path("logo-white-notext.png") }
%img{src: image_path("logo-white-notext.png") }
.row
.small-12.medium-8.medium-offset-2.columns.text-center
.alert-box

View File

@@ -4,6 +4,6 @@
%span
= t '.cart'
%span.count
%img{ src: image_pack_path("menu/icn-cart.svg") }
%img{ src: image_path("menu/icn-cart.svg") }
%span
{{ Cart.total_item_count() }}

View File

@@ -2,7 +2,7 @@
%nav.tab-bar.show-for-medium-down
%section.left
%a.left-off-canvas-toggle.menu-icon
= image_pack_tag "menu/btn-menu-mobile.png"
= image_tag "menu/btn-menu-mobile.png"
%section.left
.ofn-logo
@@ -18,7 +18,7 @@
%span
= t '.cart'
%span.count
= image_pack_tag "menu/icn-cart.svg"
= image_tag "menu/icn-cart.svg"
%span
{{ Cart.total_item_count() }}

View File

@@ -1,7 +1,7 @@
%li.user-menu.has-dropdown.not-click
%a{href: "#", class: "top-bar--menu-item-with-icon"}
%img{ src: image_pack_path("menu/icn-profile.svg") }
%img{ src: image_path("menu/icn-profile.svg") }
%span
= t '.profile'

View File

@@ -1,6 +1,6 @@
= cache_with_locale do
%li#login-link{ "data-controller": "login-modal" }
%a{"auth": "login", "data-action": "click->login-modal#call" }
%img{ src: image_pack_path("menu/icn-login.svg") }
%img{ src: image_path("menu/icn-login.svg") }
%span
= t 'label_login'

View File

@@ -9,7 +9,7 @@
"ng-debounce" => "200",
"disable-enter-with-blur" => true}
%a.clear{ type: 'button', "focus-search": true, "ng-show": 'query', "ng-click": 'clearQuery()' }
= image_pack_tag "icn-close.png"
= image_tag "icn-close.png"
.hide-for-large-up
%button{ type: 'button', "ng-click": 'toggleFilterSidebar()' }

View File

@@ -27,7 +27,7 @@
%br
- if current_distributor.whatsapp_phone.present?
%a{href: current_distributor.whatsapp_url, target: "_blank" }
%img{ src: image_pack_path("social-logos/whatsapp.svg") }
%img{ src: image_path("social-logos/whatsapp.svg") }
= current_distributor.whatsapp_phone
%br
- if current_distributor.website.present?

View File

@@ -41,5 +41,5 @@
%a.info.cvvLink{href: "/content/cvv", target: "_blank"}
(#{t(:what_is_this)})
.nine.columns
= image_pack_tag 'credit_cards/credit_card.gif', class: 'credit-card-image'
= image_tag 'credit_cards/credit_card.gif', class: 'credit-card-image'
.clear

View File

@@ -4,7 +4,7 @@
padding: 4em 2em;
background-color: black;
background-image: url("../images/home/tagline-bg.jpg");
background-image: url("../../assets/images/home/tagline-bg.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center center;

View File

@@ -4,7 +4,7 @@
}
.question-mark-icon {
background-image: url("../images/question-mark-icon.svg");
background-image: url("../../assets/images/question-mark-icon.svg");
background-size: cover;
background-repeat: no-repeat;
border-radius: 50%;

View File

@@ -60,7 +60,7 @@ ordercycle {
}
select {
background-image: url('../images/white-caret.svg');
background-image: url('../../assets/images/white-caret.svg');
background-size: 30px auto;
background-position-x: 102%;
height: 2.35em;
@@ -145,7 +145,7 @@ shop ordercycle {
select {
background-color: $white;
background-image: url('../images/black-caret.svg');
background-image: url('../../assets/images/black-caret.svg');
color: $grey-500;
font-style: italic;
}

View File

@@ -46,7 +46,7 @@ footer {
width: 100%;
border: 1px solid rgba($dark-grey, 0.35);
background-image: url("../images/tile-wide.png");
background-image: url("../../assets/images/tile-wide.png");
background-position: center center;
background-color: #bbb;
padding: 12px 0 8px 0;

View File

@@ -36,7 +36,7 @@
}
#stats.pane {
background-image: url("../images/home/background-blurred-oranges.jpg");
background-image: url("../../assets/images/home/background-blurred-oranges.jpg");
background-position: center center;
background-color: $ofn-grey;
@@ -88,7 +88,7 @@
}
.home-icon-box {
background-image: url("../images/ofn-o.png");
background-image: url("../../assets/images/ofn-o.png");
background-position: center center;
background-repeat: no-repeat;
background-size: auto 100%;
@@ -115,15 +115,15 @@
background-size: auto 100%;
&.search {
background-image: url("../images/icon-mask-magnifier.png");
background-image: url("../../assets/images/icon-mask-magnifier.png");
}
&.shop {
background-image: url("../images/icon-mask-apple.png");
background-image: url("../../assets/images/icon-mask-apple.png");
}
&.pick-up-delivery {
background-image: url("../images/icon-mask-truck.png");
background-image: url("../../assets/images/icon-mask-truck.png");
}
}
}

View File

@@ -3,7 +3,7 @@
// Generic \\
@mixin tiledPane {
background-image: url("../images/tile-wide.png");
background-image: url("../../assets/images/tile-wide.png");
background-color: $brand-colour;
background-position: center center;
@@ -177,7 +177,7 @@
@mixin producersbg {
background-color: lighten($clr-turquoise, 68%);
background-image: url("../images/producers.svg");
background-image: url("../../assets/images/producers.svg");
background-position: center 50px;
background-repeat: no-repeat;
background-size: 922px 763px;
@@ -185,13 +185,13 @@
@mixin hubsbg {
background-color: $brand-colour;
background-image: url("../images/hubs-bg.jpg");
background-image: url("../../assets/images/hubs-bg.jpg");
background-position: center center;
}
@mixin groupsbg {
background-color: lighten($clr-brick, 56%);
background-image: url("../images/groups.svg");
background-image: url("../../assets/images/groups.svg");
background-position: center 50px;
background-repeat: no-repeat;
background-size: 922px 922px;

View File

@@ -9,7 +9,7 @@ $page-alert-height: 55px;
border-left: none;
border-right: none;
background-color: #bbb;
background-image: url("../images/tile-wide.png");
background-image: url("../../assets/images/tile-wide.png");
background-position: center center;
padding: 12px 0 8px 0;
margin: 0;

View File

@@ -27,7 +27,7 @@
padding: 0 2.25em 0 2.75em;
width: 100%;
min-width: 0;
background: $white url("../images/icn-search-grey.png") 1em center no-repeat;
background: $white url("../../assets/images/icn-search-grey.png") 1em center no-repeat;
font-size: 1rem; // avoid zoom on iphone, see issue #4535
&::placeholder {

View File

@@ -298,7 +298,7 @@
}
&:after {
background-image: url("../images/edit-with-pen.svg");
background-image: url("../../assets/images/edit-with-pen.svg");
content: " ";
display: inline-block;
width: 1em;

View File

@@ -6,7 +6,7 @@
}
.question-mark-icon {
background-image: url("../images/question-mark-icon.svg");
background-image: url("../../assets/images/question-mark-icon.svg");
background-size: cover;
background-repeat: no-repeat;
border-radius: 50%;

View File

@@ -202,6 +202,8 @@ module Openfoodnetwork
config.assets.precompile += ['mail.scss']
config.assets.precompile += ['*.jpg', '*.jpeg', '*.png', '*.gif' '*.svg']
config.assets.paths += ['app/assets/images']
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = ENV.fetch("VERBOSE_QUERY_LOGS", false)

View File

@@ -1,10 +0,0 @@
module WebpackImageExtension
def image_pack_path(image)
# The Webpacker::Helper#resolve_path_to_image method is incredibly useful
# for nicely fetching Webpacker image paths, but it's private.
resolve_path_to_image(image)
end
end
Webpacker::Helper.include WebpackImageExtension

View File

@@ -9,12 +9,12 @@ default: &default
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
additional_paths: [
'vendor',
'app/webpacker/css',
'app/webpacker/fonts',
'app/webpacker/images',
'app/assets/images', # images should be outside of webpacker where possible
'engines/web/app/assets/stylesheets',
'app/components'
]
@@ -94,6 +94,6 @@ production: &production
test:
<<: *default
# Compile test packs to a separate directory
public_output_path: packs-test

View File

@@ -10,11 +10,11 @@ module FileHelper
end
def black_logo_path
Rails.root.join('app/webpacker/images/logo-black.png')
Rails.root.join('app/assets/images/logo-black.png')
end
def white_logo_path
Rails.root.join('app/webpacker/images/logo-white.png')
Rails.root.join('app/assets/images/logo-white.png')
end
def terms_pdf_file