Skip to content
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

Release 6.3 #425

Merged
merged 27 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ab2197e
Add logic for block style entry points
dmtrmrv Apr 22, 2024
1c01f08
Merge branch 'develop' into feature/339-filename-based-entrypoint-for…
dmtrmrv May 20, 2024
2ad1986
fix transform file extension for .ts and .tsx assets inside block.jso…
fabiankaegy Jul 9, 2024
bb94bf5
add test cases
fabiankaegy Jul 9, 2024
7ce09d9
Create young-guests-deliver.md
fabiankaegy Jul 9, 2024
b13498e
Merge branch 'fix/support-ts-imports-in-block-json' of github.com:10u…
fabiankaegy Jul 10, 2024
d12e20d
Merge branch 'develop' into feature/339-filename-based-entrypoint-for…
dmtrmrv Aug 2, 2024
3a5b540
Add changeset
dmtrmrv Aug 2, 2024
8b74e5a
Feature/add more flexibility (#413)
dustinrue Aug 21, 2024
be66738
Merge branch 'develop' into feature/339-filename-based-entrypoint-for…
fabiankaegy Sep 23, 2024
6e5578b
Merge branch 'feature/339-filename-based-entrypoint-for-block-specifi…
fabiankaegy Sep 23, 2024
5aef3a2
add new test case
fabiankaegy Sep 23, 2024
877b46d
update colors
fabiankaegy Sep 23, 2024
0d1e50c
update color fix lint
fabiankaegy Sep 23, 2024
bf916b1
fix remove @nest from specks
fabiankaegy Sep 23, 2024
efbe49c
fix whitespace in snapshot
fabiankaegy Sep 23, 2024
11c8108
fix mixin spelling
fabiankaegy Sep 23, 2024
2c116e6
fix: tests on windows
nicholasio Sep 23, 2024
cb646bb
Merge pull request #390 from 10up/feature/339-filename-based-entrypoi…
fabiankaegy Sep 24, 2024
7225d5c
Merge branch 'develop' into fix/support-ts-imports-in-block-json
fabiankaegy Sep 24, 2024
ee914c0
update logic and tests to pass
fabiankaegy Sep 24, 2024
95aeb0f
simplify
fabiankaegy Sep 24, 2024
75b890b
Merge pull request #415 from 10up/fix/support-ts-imports-in-block-json
fabiankaegy Sep 24, 2024
e0c129b
Merge branch 'trunk' into develop
fabiankaegy Sep 24, 2024
84d6344
fix changeset for CSS entrypoint feature
fabiankaegy Sep 24, 2024
0a04496
chore: version packages (next) (next)
github-actions[bot] Sep 24, 2024
b642d40
Merge pull request #422 from 10up/changeset-release/develop
fabiankaegy Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-pumpkins-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Simple enhancements to toolkit project command to align with devops needs.
5 changes: 5 additions & 0 deletions .changeset/lemon-owls-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": minor
---

Allow block-specific CSS entry points to get automatically generated for any CSS files in the `assets/css/blocks` directory.
18 changes: 18 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@10up/babel-preset-default": "2.1.1",
"@10up/eslint-config": "4.1.0",
"@10up/stylelint-config": "3.0.0",
"10up-toolkit": "6.2.2",
"tenup-theme": "1.1.5-next.7",
"@10up/component-accordion": "2.1.5",
"@10up/library-ts-test": "2.1.5"
},
"changesets": [
"eight-pumpkins-provide",
"lemon-owls-invent",
"young-guests-deliver"
]
}
5 changes: 5 additions & 0 deletions .changeset/young-guests-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Fix: transform file extension for .ts and .tsx assets inside block.json files
11 changes: 11 additions & 0 deletions packages/toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 6.3.0-next.0

### Minor Changes

- 3a5b540: Allow block-specific CSS entry points to get automatically generated for any CSS files in the `assets/css/blocks` directory.

### Patch Changes

- 8b74e5a: Simple enhancements to toolkit project command to align with devops needs.
- 7ce09d9: Fix: transform file extension for .ts and .tsx assets inside block.json files

## 6.2.2

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.wp-block-heading {

@mixin margin-trim;

@media (--bp-small) {
padding: 40px;
}
}
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;
}
}
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);
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;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "test-build-project-global-css",
"10up-toolkit": {
"loadBlockSpecificStyles": true,
"paths": {
"srcDir": "./__fixtures__/assets/",
"blocksStyles": "./__fixtures__/assets/css/blocks/",
"cssLoaderPaths": ["./__fixtures__/assets/css", "./includes/blocks"],
"globalStylesDir": "./__fixtures__/assets/css/globals/",
"globalMixinsDir": "./__fixtures__/assets/css/mixins/"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* 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',
'blocks',
'autoenqueue',
'core',
'heading.css',
);

expect(fs.existsSync(frontendCss)).toBeTruthy();
expect(
fs.existsSync(
path.join(__dirname, 'dist', 'blocks', 'autoenqueue', 'core', 'heading.asset.php'),
),
).toBeTruthy();

const compiledCSS = fs.readFileSync(frontendCss).toString();

// expect the compiled CSS to contain "min-width: 30em"
expect(compiledCSS).toMatch('min-width: 30em');
});
});
71 changes: 36 additions & 35 deletions packages/toolkit/config/__tests__/__fixtures__/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,52 @@


:root {
--primary-font: 'Mr George', Arial, Helvetica, sans-serif;
--primary-font: "Mr George", arial, helvetica, sans-serif;
}

@font-face {
font-family: 'Mr George';
src: url('./assets/fonts/MrGeorgeHeavy.ttf') format('truetype');
font-weight: 900
font-family: "Mr George";
font-weight: 900;
src: url("./assets/fonts/MrGeorgeHeavy.ttf") format("truetype");
}

@font-face {
font-family: 'Mr George';
src: url('./assets/fonts/MrGeorge.ttf') format('truetype');
font-weight: 400
font-family: "Mr George";
font-weight: 400;
src: url("./assets/fonts/MrGeorge.ttf") format("truetype");
}

.accordion-header {
border-bottom: 1px solid #303030;
cursor: pointer;
font-size: 1em;
padding: 10px 0 10px 20px;
position: relative;
text-align: left;
width: 100%;

&:before {
content: "+";
left: 5px;
position: absolute;
top: 8px;
}

&.is-active:before {
content: "-";
}
border-bottom: 1px solid #303030;
cursor: pointer;
font-size: 1em;
padding: 10px 0 10px 20px;
position: relative;
text-align: left;
width: 100%;

&::before {
content: "+";
left: 5px;
position: absolute;
top: 8px;
}

&.is-active::before {
content: "-";
}
}

.accordion-content {
@nest .js & {
display: none;
visibility: hidden;

&.is-active {
border-bottom: 1px solid #303030;
display: block;
visibility: visible;
}
}

.js & {
display: none;
visibility: hidden;

&.is-active {
border-bottom: 1px solid #303030;
display: block;
visibility: visible;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,45 +183,45 @@ exports[`postcss properly transforms css 1`] = `

exports[`postcss transforms accordion.css properly 1`] = `
":root {
--primary-font: 'Mr George', Arial, Helvetica, sans-serif;
--primary-font: "Mr George", arial, helvetica, sans-serif;
}
@font-face {
font-family: 'Mr George';
src: url('./assets/fonts/MrGeorgeHeavy.ttf') format('truetype');
font-weight: 900
font-family: "Mr George";
font-weight: 900;
src: url("./assets/fonts/MrGeorgeHeavy.ttf") format("truetype");
}
@font-face {
font-family: 'Mr George';
src: url('./assets/fonts/MrGeorge.ttf') format('truetype');
font-weight: 400
font-family: "Mr George";
font-weight: 400;
src: url("./assets/fonts/MrGeorge.ttf") format("truetype");
}
.accordion-header {
border-bottom: 1px solid #303030;
cursor: pointer;
font-size: 1em;
padding: 10px 0 10px 20px;
position: relative;
text-align: left;
width: 100%;
}
.accordion-header:before {
content: "+";
left: 5px;
position: absolute;
top: 8px;
}
.accordion-header.is-active:before {
content: "-";
}
.js .accordion-content {
display: none;
visibility: hidden;
border-bottom: 1px solid #303030;
cursor: pointer;
font-size: 1em;
padding: 10px 0 10px 20px;
position: relative;
text-align: left;
width: 100%;
}
.accordion-header::before {
content: "+";
left: 5px;
position: absolute;
top: 8px;
}
.accordion-header.is-active::before {
content: "-";
}
.js .accordion-content {
display: none;
visibility: hidden;
}
.js .accordion-content.is-active {
border-bottom: 1px solid #303030;
display: block;
visibility: visible;
}
border-bottom: 1px solid #303030;
display: block;
visibility: visible;
}
"
`;

Expand Down
9 changes: 5 additions & 4 deletions packages/toolkit/config/paths.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module.exports = {
srcDir: './assets/',
cssLoaderPaths: ['./assets/css', './includes/blocks'],
copyAssetsDir: './assets/',
blocksDir: './includes/blocks/',
globalStylesDir: './assets/css/globals/',
blocksStyles: './assets/css/blocks/',
copyAssetsDir: './assets/',
cssLoaderPaths: ['./assets/css', './includes/blocks'],
globalMixinsDir: './assets/css/mixins/',
globalStylesDir: './assets/css/globals/',
srcDir: './assets/',
};
29 changes: 27 additions & 2 deletions packages/toolkit/config/webpack/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ const removeDistFolder = (file) => {
module.exports = ({
buildType = 'script',
isPackage,
projectConfig: { devServer, paths, useBlockAssets, filenames },
projectConfig: { devServer, paths, useBlockAssets, filenames, loadBlockSpecificStyles },
packageConfig: { packageType, source, main, umd, libraryName },
buildFiles,
moduleBuildFiles,
}) => {
let additionalEntrypoints = {};

if (useBlockAssets) {
// override default block filenames
filenames.block = 'blocks/[name].js';
Expand Down Expand Up @@ -105,13 +106,37 @@ module.exports = ({
}, {});
}

const blockStyleEntryPoints = {};

// Logic for loading CSS files per block.
if (loadBlockSpecificStyles) {
// get all stylesheets located in the assets/css/blocks directory and subdirectories
const blockStylesheetDirectory = resolve(process.cwd(), paths.blocksStyles).replace(
/\\/g,
'/',
);

// get all stylesheets in the blocks directory
const stylesheets = glob(`${blockStylesheetDirectory}/**/*.css`, {
absolute: true,
});

stylesheets.forEach((filePath) => {
const blockName = filePath
.replace(`${blockStylesheetDirectory}/`, '')
.replace(extname(filePath), '');

blockStyleEntryPoints[`autoenqueue/${blockName}`] = resolve(filePath);
});
}

if (buildType === 'module') {
Object.assign(moduleBuildFiles, additionalEntrypoints);
return moduleBuildFiles;
}

// merge the new entrypoints with the existing ones
Object.assign(buildFiles, additionalEntrypoints);
Object.assign(buildFiles, additionalEntrypoints, blockStyleEntryPoints);

if (isPackage) {
const config = {};
Expand Down
Loading
Loading