Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Jan 5, 2022
1 parent c7e1b20 commit 1f958b8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
12 changes: 6 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

require_relative 'config/application'

# namespace :assets do
# task :precompile do
# end
# task :clobber do
# end
# end
namespace :erik do
task :setup do
puts `cp public/assets/.manifest.json app/javascript/.manifest.json`
end
end

Rails.application.load_tasks

Rake::Task['javascript:build'].enhance(%w[erik:setup])
5 changes: 4 additions & 1 deletion app/javascript/components/common/GraphicalIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React from 'react'
import manifest from '../../.manifest.json'

console.log(manifest)

export function GraphicalIcon({
icon,
Expand All @@ -15,7 +18,7 @@ export function GraphicalIcon({
(className) => className.length > 0
)

const iconFile = require(`../../images/${category || 'icons'}/${icon}.svg`)
const iconFile = manifest[`images/${category || 'icons'}/${icon}.svg`]

return hex ? (
<div className={classNames.join(' ')}>
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/components/common/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as React from 'react'
import manifest from '../../.manifest.json'

console.log(manifest)

export function Icon({
icon,
Expand All @@ -15,8 +18,7 @@ export function Icon({
if (className !== undefined) {
classNames.push(className)
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
const iconFile = require(`../../images/${category}/${icon}.svg`)
const iconFile = manifest[`images/${category}/${icon}.svg`]

return <img src={iconFile} alt={alt} className={classNames.join(' ')} />
}
14 changes: 7 additions & 7 deletions app/javascript/components/common/imageErrorHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const errorIcon = require(`../../../images/graphics/missing-exercise.svg`)
// const errorIcon = require(`../../../images/graphics/missing-exercise.svg`)

export const imageErrorHandler = (
e: React.SyntheticEvent<HTMLImageElement, Event>
) => {
const el = e.target as HTMLImageElement
if ((el.src = errorIcon)) {
return
}
el.onerror = null
el.src = errorIcon
// const el = e.target as HTMLImageElement
// if ((el.src = errorIcon)) {
// return
// }
// el.onerror = null
// el.src = errorIcon
}
6 changes: 3 additions & 3 deletions app/javascript/esbuild.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

console.log('yay')
const svgrPlugin = require('esbuild-plugin-svgr')
const ImportGlobPlugin = require('esbuild-plugin-import-glob')

Expand All @@ -12,7 +12,7 @@ for (const k in process.env) {
*/

/* TODO: Get a map of all the images (name -> digest name)
* and pass this into the config to replace the dynamic requires
* and pass this into the config to replace the dynamic requires
* in Icon/GraphicalIcon which don't work with esbuild */

require('esbuild')
Expand All @@ -25,7 +25,7 @@ require('esbuild')
bundle: true,
sourcemap: true,
outdir: '.built-assets',
tsconfig: "./tsconfig.json",
tsconfig: './tsconfig.json',
define: {
'process.env.BUGSNAG_API_KEY': '"938ae3d231c5455e5c6597de1b1467af"',
},
Expand Down

0 comments on commit 1f958b8

Please sign in to comment.