Skip to content

Commit dccbb87

Browse files
authored
Merge pull request #17 from udaypydi/feat/image-loader
Feat/image loader
2 parents 8824827 + 7c78472 commit dccbb87

File tree

10 files changed

+74
-6
lines changed

10 files changed

+74
-6
lines changed

config/assetsMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = '';

config/webpack.dev.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ module.exports = {
3131
{
3232
test: /\.css$/i,
3333
use: ['style-loader', 'css-loader'],
34-
}
34+
},
35+
{
36+
test: /\.(png|jpe?g|gif)$/i,
37+
use: [
38+
{
39+
loader: 'file-loader',
40+
},
41+
],
42+
},
3543
]
3644
},
3745
plugins: [

config/webpack.prod.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ module.exports = {
3232
{
3333
test: /\.css$/i,
3434
use: ['style-loader', 'css-loader'],
35-
}
35+
},
36+
{
37+
test: /\.(png|jpe?g|gif)$/i,
38+
use: [
39+
{
40+
loader: 'file-loader',
41+
},
42+
],
43+
},
3644
]
3745
},
3846
plugins: [

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
clearMocks: true,
77
coverageDirectory: "coverage",
88
moduleNameMapper: {
9+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/config/assetsMock.js",
910
"\\.(css|less|scss)$": "identity-obj-proxy"
1011
},
1112
testEnvironment: "jsdom",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"eslint-plugin-jsx-a11y": "^6.2.3",
4343
"eslint-plugin-react": "^7.19.0",
4444
"eslint-plugin-react-hooks": "^2.5.1",
45+
"file-loader": "^6.0.0",
4546
"html-webpack-plugin": "^4.0.4",
4647
"identity-obj-proxy": "^3.0.0",
4748
"jest": "^25.3.0",

src/__tests__/__snapshots__/app.spec.js.snap

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,16 @@ exports[`should take a snapshot 1`] = `
55
<div
66
class="App--Container"
77
>
8-
Welcome to React Boilerplate!
8+
<p
9+
class="App--Title"
10+
>
11+
Welcome To React Boilerplate
12+
</p>
13+
<img
14+
alt="React Logo"
15+
class="App--Image"
16+
src=""
17+
/>
918
</div>
1019
</DocumentFragment>
1120
`;

src/app.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React from 'react';
2+
import logo from './logo.png';
23
import './app.scss';
34

45
export default function App() {
56
return (
6-
<div className="App--Container">Welcome to React Boilerplate!</div>
7+
<div className="App--Container">
8+
<p className="App--Title">Welcome To React Boilerplate</p>
9+
<img src={logo} alt="React Logo" className="App--Image" />
10+
</div>
711
);
812
}

src/app.scss

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1-
$bg-color: grey;
1+
$bg-color: #282b33;
22
$txt-color: white;
3+
$primary-color: #61dbfc;
4+
5+
body {
6+
margin: 0px;
7+
}
38

49
.App--Container {
510
display: flex;
611
flex: 1;
12+
justify-content: center;
13+
align-items: center;
14+
flex-direction: column;
715
background: $bg-color;
816
color: $txt-color;
9-
}
17+
padding: 0;
18+
margin: 0;
19+
color: $primary-color;
20+
21+
.App--Image {
22+
height: 200px;
23+
}
24+
25+
.App--Title {
26+
font-size: 2rem;
27+
}
28+
}

src/logo.png

59.9 KB
Loading

yarn.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3712,6 +3712,14 @@ file-entry-cache@^5.0.1:
37123712
dependencies:
37133713
flat-cache "^2.0.1"
37143714

3715+
file-loader@^6.0.0:
3716+
version "6.0.0"
3717+
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.0.0.tgz#97bbfaab7a2460c07bcbd72d3a6922407f67649f"
3718+
integrity sha512-/aMOAYEFXDdjG0wytpTL5YQLfZnnTmLNjn+AIrJ/6HVnTfDqLsVKUUwkDf4I4kgex36BvjuXEn/TX9B/1ESyqQ==
3719+
dependencies:
3720+
loader-utils "^2.0.0"
3721+
schema-utils "^2.6.5"
3722+
37153723
file-uri-to-path@1.0.0:
37163724
version "1.0.0"
37173725
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
@@ -5489,6 +5497,15 @@ loader-utils@^1.1.0, loader-utils@^1.2.3, loader-utils@^1.4.0:
54895497
emojis-list "^3.0.0"
54905498
json5 "^1.0.1"
54915499

5500+
loader-utils@^2.0.0:
5501+
version "2.0.0"
5502+
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0"
5503+
integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==
5504+
dependencies:
5505+
big.js "^5.2.2"
5506+
emojis-list "^3.0.0"
5507+
json5 "^2.1.2"
5508+
54925509
locate-path@^2.0.0:
54935510
version "2.0.0"
54945511
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"

0 commit comments

Comments
 (0)