From 231d12562a223ddf9282c09dabe47eb4b4b64d0a Mon Sep 17 00:00:00 2001 From: Caio Lucas Date: Thu, 24 Mar 2022 11:02:00 -0300 Subject: [PATCH 1/2] Refactor webpack to accept svg imports --- assets/reactjs-icon.svg | 1 + src/@types/image.d.ts | 3 ++- src/components/Greetings/index.tsx | 3 ++- webpack/rules.webpack.js | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 assets/reactjs-icon.svg diff --git a/assets/reactjs-icon.svg b/assets/reactjs-icon.svg new file mode 100644 index 00000000..1c5118db --- /dev/null +++ b/assets/reactjs-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/@types/image.d.ts b/src/@types/image.d.ts index 9ddf0c34..7d295f89 100644 --- a/src/@types/image.d.ts +++ b/src/@types/image.d.ts @@ -1,4 +1,5 @@ declare module '*.png'; declare module '*.jpeg'; declare module '*.jpg'; -declare module '*.gif'; \ No newline at end of file +declare module '*.gif'; +declare module '*.svg'; \ No newline at end of file diff --git a/src/components/Greetings/index.tsx b/src/components/Greetings/index.tsx index 83de3f3d..b6ae07ec 100644 --- a/src/components/Greetings/index.tsx +++ b/src/components/Greetings/index.tsx @@ -1,5 +1,6 @@ import { Button } from '../Button' import { Container, Image, Text } from './styles' +import ReactIcon from '../../../assets/reactjs-icon.svg'; export function Greetings() { function handleSayHello() { @@ -11,7 +12,7 @@ export function Greetings() { return ( ReactJS logo An Electron boilerplate including TypeScript, React, Jest and ESLint. diff --git a/webpack/rules.webpack.js b/webpack/rules.webpack.js index 7cc788df..a5a57bf0 100644 --- a/webpack/rules.webpack.js +++ b/webpack/rules.webpack.js @@ -21,7 +21,7 @@ module.exports = [ } }, { - test: /\.(png|jpe?g|gif)$/i, + test: /\.(png|jpe?g|gif|svg)$/i, loader: 'file-loader', options: { name: '[path][name].[ext]', From 87a2f25230e839ba19cc265b5dabe4b3801fea74 Mon Sep 17 00:00:00 2001 From: Caio Lucas Date: Thu, 24 Mar 2022 11:02:00 -0300 Subject: [PATCH 2/2] feat: add configuration to accept to accept svg imports --- assets/reactjs-icon.svg | 1 + src/@types/image.d.ts | 3 ++- src/components/Greetings/index.tsx | 3 ++- webpack/rules.webpack.js | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 assets/reactjs-icon.svg diff --git a/assets/reactjs-icon.svg b/assets/reactjs-icon.svg new file mode 100644 index 00000000..1c5118db --- /dev/null +++ b/assets/reactjs-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/@types/image.d.ts b/src/@types/image.d.ts index 9ddf0c34..7d295f89 100644 --- a/src/@types/image.d.ts +++ b/src/@types/image.d.ts @@ -1,4 +1,5 @@ declare module '*.png'; declare module '*.jpeg'; declare module '*.jpg'; -declare module '*.gif'; \ No newline at end of file +declare module '*.gif'; +declare module '*.svg'; \ No newline at end of file diff --git a/src/components/Greetings/index.tsx b/src/components/Greetings/index.tsx index 83de3f3d..b6ae07ec 100644 --- a/src/components/Greetings/index.tsx +++ b/src/components/Greetings/index.tsx @@ -1,5 +1,6 @@ import { Button } from '../Button' import { Container, Image, Text } from './styles' +import ReactIcon from '../../../assets/reactjs-icon.svg'; export function Greetings() { function handleSayHello() { @@ -11,7 +12,7 @@ export function Greetings() { return ( ReactJS logo An Electron boilerplate including TypeScript, React, Jest and ESLint. diff --git a/webpack/rules.webpack.js b/webpack/rules.webpack.js index 7cc788df..a5a57bf0 100644 --- a/webpack/rules.webpack.js +++ b/webpack/rules.webpack.js @@ -21,7 +21,7 @@ module.exports = [ } }, { - test: /\.(png|jpe?g|gif)$/i, + test: /\.(png|jpe?g|gif|svg)$/i, loader: 'file-loader', options: { name: '[path][name].[ext]',