From 052eaed428e9d03d59d0d083c7b83c4a4f94140b Mon Sep 17 00:00:00 2001 From: lutangar Date: Fri, 3 Jul 2020 17:45:45 +0200 Subject: [PATCH] fix(profiles): Serve static images from profiles page --- .env.development.example | 1 + .env.example | 1 + .env.proding | 1 + .env.production | 1 + .env.staging | 1 + .../App/Profiles/Profile/ProfileBanner.tsx | 5 +++-- src/index.d.ts | 1 + webpack.profiles.config.js | 15 +++++++++++++++ 8 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/index.d.ts diff --git a/.env.development.example b/.env.development.example index 848bf525a..c5fdf7b53 100644 --- a/.env.development.example +++ b/.env.development.example @@ -23,3 +23,4 @@ SEND_IN_BLUE_TOKEN=token CHROME_EXTENSION_ID= FIREFOX_EXTENSION_ID= PROFILES_ORIGIN=http://localhost:8080/ +PROFILES_ASSETS_PATH=/ diff --git a/.env.example b/.env.example index 33b76e390..9193c9c7f 100644 --- a/.env.example +++ b/.env.example @@ -11,3 +11,4 @@ SEND_IN_BLUE_TOKEN= CHROME_EXTENSION_ID= FIREFOX_EXTENSION_ID= PROFILES_ORIGIN= +PROFILES_ASSETS_PATH= diff --git a/.env.proding b/.env.proding index d6b637730..6d347a5f8 100644 --- a/.env.proding +++ b/.env.proding @@ -18,3 +18,4 @@ CHROME_EXTENSION_ID=mepoelfgpameiagpkgpjphnbgampgffm FIREFOX_EXTENSION_ID={72aad822-62f5-4663-a8f0-025b2f9a3dd5} BABEL_ENV=production PROFILES_ORIGIN=http://localhost:8080 +PROFILES_ASSETS_PATH=https://profiles.dismoi.io diff --git a/.env.production b/.env.production index 2173b582d..2bd04eebc 100644 --- a/.env.production +++ b/.env.production @@ -17,3 +17,4 @@ SEND_CONTRIBUTION_TO=contribution@dismoi.io CHROME_EXTENSION_ID=fpjlnlnbacohacebkadbbjebbipcknbg FIREFOX_EXTENSION_ID=@lmem PROFILES_ORIGIN=https://www.dismoi.io +PROFILES_ASSETS_PATH=https://profiles.dismoi.io diff --git a/.env.staging b/.env.staging index 1b42b2f54..a1568e17b 100644 --- a/.env.staging +++ b/.env.staging @@ -17,3 +17,4 @@ SEND_CONTRIBUTION_TO=contribution@bulles.fr CHROME_EXTENSION_ID=nfabbfkbbbcebdmnocndhdombaffkaog FIREFOX_EXTENSION_ID={7d0d2553-c311-4acd-a170-f9a4714eb2c0} BABEL_ENV=production +PROFILES_ASSETS_PATH=https://profiles.dismoi.io diff --git a/src/app/profiles/App/Profiles/Profile/ProfileBanner.tsx b/src/app/profiles/App/Profiles/Profile/ProfileBanner.tsx index 860907d6e..0669ddd29 100644 --- a/src/app/profiles/App/Profiles/Profile/ProfileBanner.tsx +++ b/src/app/profiles/App/Profiles/Profile/ProfileBanner.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import { StatefulContributor } from 'app/lmem/contributor'; import styled from 'styled-components'; +import { StatefulContributor } from 'app/lmem/contributor'; +import defaultProfileBannerImage from 'assets/img/profile-banner.jpg'; const ProfileBannerContainer = styled.div<{ default: boolean; @@ -43,7 +44,7 @@ const ProfileBanner = ({ contributor }: ProfileBannerProps) => { src={ contributor && contributor.banner ? contributor.banner - : '/img/profile-banner.jpg' + : defaultProfileBannerImage } alt={getBannerAlt(contributor)} /> diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 000000000..20c9243ae --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1 @@ +declare module '*.jpg'; diff --git a/webpack.profiles.config.js b/webpack.profiles.config.js index 9f8ff4b79..66269f405 100644 --- a/webpack.profiles.config.js +++ b/webpack.profiles.config.js @@ -33,6 +33,21 @@ module.exports = function webpack(env = {}, argv = {}) { return { ...defaultWebpackConfig, + module: { + rules: [ + ...defaultWebpackConfig.module.rules, + { + test: /\.(png|jpe?g|gif)$/i, + loader: 'file-loader', + options: { + publicPath: process.env.PROFILES_ASSETS_PATH, + name: '[path][name].[ext]', + context: 'src/assets', + }, + }, + ] + }, + entry: [ 'core-js/stable', 'regenerator-runtime/runtime',