-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/339-filename-based-entrypoint-for…
…-block-specific-CSS
- Loading branch information
Showing
35 changed files
with
375 additions
and
56 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 @@ | ||
./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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./dist |
1 change: 1 addition & 0 deletions
1
packages/toolkit/__tests__/build-project-modules/__fixtures__/assets/css/admin-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 @@ | ||
.admin-class { color: blue; } |
1 change: 1 addition & 0 deletions
1
packages/toolkit/__tests__/build-project-modules/__fixtures__/assets/css/frontend.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 @@ | ||
.test { color: red; } |
3 changes: 3 additions & 0 deletions
3
packages/toolkit/__tests__/build-project-modules/__fixtures__/assets/js/admin.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,3 @@ | ||
import '../css/admin-styles.css'; | ||
|
||
export const admin = () => {}; |
12 changes: 12 additions & 0 deletions
12
packages/toolkit/__tests__/build-project-modules/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,12 @@ | ||
{ | ||
"name": "test-build-project", | ||
"10up-toolkit": { | ||
"useBlockAssets": false, | ||
"entry": { | ||
"frontend-css": "./__fixtures__/assets/css/frontend.css" | ||
}, | ||
"moduleEntry": { | ||
"admin": "./__fixtures__/assets/js/admin.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,35 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import spawn from 'cross-spawn'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
describe('build a project with moduleEntry', () => { | ||
it('builds and compiles js and css', async () => { | ||
spawn.sync('node', ['../../scripts/build', '--block-modules'], { | ||
cwd: __dirname, | ||
}); | ||
|
||
const adminJsPath = path.join(__dirname, 'dist', 'js', 'admin.js'); | ||
|
||
expect(fs.existsSync(adminJsPath)).toBeTruthy(); | ||
expect(fs.existsSync(path.join(__dirname, 'dist', 'css', 'frontend-css.css'))).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(__dirname, 'dist', 'css', 'frontend-css.asset.php')), | ||
).toBeTruthy(); | ||
|
||
// ensure admin is a module | ||
const adminJs = fs.readFileSync(adminJsPath).toString(); | ||
expect(adminJs).toMatch(/export {.*};/); | ||
}); | ||
|
||
it('extracts css imported in js files', () => { | ||
spawn.sync('node', ['../../scripts/build', '--block-modules'], { | ||
cwd: __dirname, | ||
}); | ||
// chunk name for css imported in js matches the js entry point | ||
expect(fs.existsSync(path.join(__dirname, 'dist', 'css', 'admin.css'))).toBeTruthy(); | ||
|
||
// this should not exist since it is not an entry point on its own | ||
expect(fs.existsSync(path.join(__dirname, 'dist', 'css', 'admin-styles.css'))).toBeFalsy(); | ||
}); | ||
}); |
Oops, something went wrong.