-
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from dilanx:postcss-fix
Fixed issue where postcss plugins weren't being applied
- Loading branch information
Showing
13 changed files
with
994 additions
and
41 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
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
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
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 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
test('Should have the expected styles', async () => { | ||
const expectedStyles = "::-webkit-input-placeholder{color:gray}::placeholder{color:gray}.image{background-image:url(https://google.com)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:2dppx){.image{background-image:url(http://nxetflix.com)}}"; | ||
|
||
//we check if the compiled css is what we expect for autoprefixer | ||
const prom = new Promise((resolve, reject) => { | ||
fs.readdir('./test/integration/fixtures/autoprefixer-test/test-project/build/static/css', (err, files) => { | ||
if (err) reject(); | ||
//we don't know what the bundle name will be beforehand | ||
const cssFile = files.find(file => path.extname(file) === '.css'); | ||
expect(cssFile).not.toBe(0); | ||
|
||
fs.readFile(`./test/integration/fixtures/autoprefixer-test/test-project/build/static/css/${cssFile}`, 'utf8', (err, data) => { | ||
if (err) reject(); | ||
data = data.substring(0, data.indexOf("/*")-1); | ||
expect(data).toBe(expectedStyles); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
await prom; | ||
}); |
11 changes: 11 additions & 0 deletions
11
test/integration/fixtures/autoprefixer-test/test-package-files/craco.config.js
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,11 @@ | ||
const webpack = require('webpack'); | ||
const isDevelopment = false; | ||
module.exports = { | ||
style: { | ||
postcss: { | ||
plugins: [ | ||
require('autoprefixer')() | ||
] | ||
} | ||
} | ||
}; |
23 changes: 23 additions & 0 deletions
23
test/integration/fixtures/autoprefixer-test/test-package-files/package.json
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,23 @@ | ||
{ | ||
"name": "craco-postcss-test", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"web-vitals": "^3.3.1", | ||
"autoprefixer": "^10.4.14" | ||
}, | ||
"scripts": { | ||
"start": "craco start", | ||
"build": "craco build", | ||
"test": "craco test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
test/integration/fixtures/autoprefixer-test/test-package-files/public/index.html
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>React App</title> | ||
<link rel="stylesheet" href="index.css" /> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
test/integration/fixtures/autoprefixer-test/test-package-files/src/index.css
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,12 @@ | ||
::placeholder { | ||
color: gray; | ||
} | ||
|
||
.image { | ||
background-image: url("https://google.com"); | ||
} | ||
@media (min-resolution: 2dppx) { | ||
.image { | ||
background-image: url("http://nxetflix.com"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/integration/fixtures/autoprefixer-test/test-package-files/src/index.js
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,12 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<div className="container"> | ||
<h1>Hi!</h1> | ||
</div> | ||
</React.StrictMode>, | ||
document.getElementById('root') | ||
); |
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 |
---|---|---|
|
@@ -4,7 +4,8 @@ const { execSync, spawn } = require('child_process'); | |
|
||
beforeAll(async () => { | ||
// Start a local server to serve the test project | ||
const server = spawn('npx', ['serve', '-s', 'build', '-l', global.PORT], { | ||
// We cached serve by installing it locally | ||
const server = spawn('npx', ['[email protected]', '-s', 'build', '-l', global.PORT], { | ||
cwd: join(__dirname, 'test-project'), | ||
}); | ||
|
||
|
@@ -19,7 +20,7 @@ beforeAll(async () => { | |
}); | ||
}); | ||
|
||
test('Should have the expected styles', async () => { | ||
test('Should have the expected custom craco variable name', async () => { | ||
await page.goto(global.URL, { waitUntil: 'domcontentloaded' }); //todo: make the url changeble | ||
|
||
const cracoTestText = await page.$eval( | ||
|
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
Oops, something went wrong.