-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle PostCSS Global Data Plugin with default configuration #389
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a01b275
install @csstools/postcss-global-data npm package
fabiankaegy af32612
move sample theme project config arround
fabiankaegy 604870b
add sample mixin & breakpoint usage
fabiankaegy 71b8eb5
add new paths for global styles and mixins folders
fabiankaegy a9c30b0
update postcss config to auto include global styles & mixin files
fabiankaegy 0800028
Create thin-geckos-sparkle.md
fabiankaegy 918f10d
update snapshots
fabiankaegy 1ac6710
fix linting issue in sample theme
fabiankaegy 427eccb
add basic tests
nicholasio 697963e
update tests
nicholasio 52e5b67
fix update paths to account for fixtures
fabiankaegy 054ae44
fix test case
fabiankaegy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,5 @@ | ||
--- | ||
"10up-toolkit": minor | ||
--- | ||
|
||
Bundle PostCSS Global Data Plugin with default configuration |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
./dist |
10 changes: 10 additions & 0 deletions
10
...es/toolkit/__tests__/build-project-global-css/__fixtures__/assets/css/frontend/styles.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,10 @@ | ||
html { | ||
background: #f5f5f5; | ||
padding: 20px; | ||
|
||
@mixin margin-trim; | ||
|
||
@media (--bp-small) { | ||
padding: 40px; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...lkit/__tests__/build-project-global-css/__fixtures__/assets/css/globals/media-queries.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,13 @@ | ||
/* | ||
* Media Queries | ||
*/ | ||
@custom-media --bp-tiny ( min-width: 25em ); /* 400px */ | ||
@custom-media --bp-small ( min-width: 30em ); /* 480px */ | ||
@custom-media --bp-medium ( min-width: 48em ); /* 768px */ | ||
@custom-media --bp-large ( min-width: 64em ); /* 1024px */ | ||
@custom-media --bp-xlarge ( min-width: 80em ); /* 1280px */ | ||
@custom-media --bp-xxlarge ( min-width: 90em ); /* 1440px */ | ||
|
||
/* WP Core Breakpoints (used for the admin bar for example) */ | ||
@custom-media --wp-small ( min-width: 600px ); | ||
@custom-media --wp-medium-max (max-width: 782px); |
15 changes: 15 additions & 0 deletions
15
...toolkit/__tests__/build-project-global-css/__fixtures__/assets/css/mixins/margin-trim.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,15 @@ | ||
@define-mixin margin-trim { | ||
margin-trim: block; | ||
|
||
/* Fallback for browsers that don't support margin-trim */ | ||
@supports not (margin-trim: block) { | ||
|
||
& > *:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
& > *:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/toolkit/__tests__/build-project-global-css/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,15 @@ | ||
{ | ||
"name": "test-build-project-global-css", | ||
"10up-toolkit": { | ||
"useBlockAssets": false, | ||
"entry": { | ||
"frontend-css": "./__fixtures__/assets/css/frontend/styles.css" | ||
}, | ||
"paths": { | ||
"srcDir": "./__fixtures__/assets/", | ||
"cssLoaderPaths": ["./__fixtures__/assets/css", "./includes/blocks"], | ||
"globalStylesDir": "./__fixtures__/assets/css/globals/", | ||
"globalMixinsDir": "./__fixtures__/assets/css/mixins/" | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/toolkit/__tests__/build-project-global-css/test.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,24 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import spawn from 'cross-spawn'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
describe('build a project', () => { | ||
it('builds and compiles css with global css', async () => { | ||
spawn.sync('node', ['../../scripts/build'], { | ||
cwd: __dirname, | ||
}); | ||
|
||
const frontendCss = path.join(__dirname, 'dist', 'css', 'frontend-css.css'); | ||
|
||
expect(fs.existsSync(frontendCss)).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'css', 'frontend-css.asset.php')), | ||
).toBeTruthy(); | ||
|
||
const compiledCSS = fs.readFileSync(frontendCss).toString(); | ||
|
||
// expect the compiled CSS to contain "min-width: 30em" | ||
expect(compiledCSS).toMatch('min-width: 30em'); | ||
}); | ||
}); |
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
1 change: 0 additions & 1 deletion
1
projects/10up-theme/assets/css/frontend/global/index.css
100755 → 100644
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
@import url("colors.css"); | ||
@import url("media-queries.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
File renamed without changes.
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,15 @@ | ||
@define-mixin margin-trim { | ||
margin-trim: block; | ||
|
||
/* Fallback for browsers that don't support margin-trim */ | ||
@supports not (margin-trim: block) { | ||
|
||
& > *:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
& > *:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabiankaegy I set up this test and for some reason, this line breaks building this file! It doesn't even create the css file.
Did I miss something? I'm wondering if this mixins is undefined and therefore breaking everyting. On the other hand I'd like to understand why this test doesn't even generate the css file with this line and it also doesn't give any error.
To run tests locally just do
npm run test -w=packages/toolkit -- --watch
you can run the tests then inspect the dist folder for each test to see what toolkit is outputtingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicholasio it appears that the issue was due to the
paths
not being set correctly for the__fixtures__
path. See 52e5b67There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense! Thanks!