-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92f1189
commit b43f3e6
Showing
6 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const testSetup = require('../__shared__/test-setup'); | ||
|
||
const fs = require('fs-extra'); | ||
const globby = require('globby'); | ||
const path = require('path'); | ||
|
||
test('optimizes in production', async () => { | ||
const { fulfilled } = await testSetup.scripts.build(); | ||
expect(fulfilled).toBe(true); | ||
|
||
const buildDir = path.join(testSetup.testDirectory, 'build'); | ||
const builtImageFile = path.join( | ||
buildDir, | ||
globby.sync('**/*.png', { cwd: buildDir }).pop() | ||
); | ||
const recievedBuf = fs.readFileSync(builtImageFile); | ||
|
||
const expectedImageFile = path.join( | ||
testSetup.templateDirectory, | ||
'./src/images/webpack-optimized.png' | ||
); | ||
const expectedBuf = fs.readFileSync(expectedImageFile); | ||
|
||
expect(recievedBuf).toStrictEqual(expectedBuf); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"react": "latest", | ||
"react-dom": "latest" | ||
} | ||
} |
Binary file added
BIN
+31.4 KB
test/fixtures/webpack-image-optimization/src/images/webpack-optimized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+65 KB
test/fixtures/webpack-image-optimization/src/images/webpack-unoptimized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#root { | ||
width: 300px; | ||
height: 300px; | ||
background: url(./images/webpack-unoptimized.png) center/cover no-repeat; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
|
||
ReactDOM.render(<div />, document.getElementById('root')); |