Skip to content

Commit

Permalink
Update postcss-loader configs (#31583)
Browse files Browse the repository at this point in the history
A few years ago postcss-loader added the ability to specify plugins as
an array of plugin objects rather than as an object mapping plugin names
to configs.

Taking advantage of this lets us not have to use `NODE_PATH` for webpack
invocations all over the place to allow postcss-loader to find its
plugins.
  • Loading branch information
anomiex authored Jun 27, 2023
1 parent 31f026a commit abe75af
Show file tree
Hide file tree
Showing 40 changed files with 121 additions and 86 deletions.
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Postcss config no longer needs NODE_PATH, but storybook still does. Update comment accordingly. No change to the project itself.


2 changes: 1 addition & 1 deletion projects/js-packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"//": "# We set NODE_PATH here so postcss-loader can find its plugins with pnpm 7. See https://github.com/pnpm/pnpm/discussions/3536#discussioncomment-2688984",
"//": "# We set NODE_PATH here so storybook can find its plugins with pnpm 7. See https://github.com/pnpm/pnpm/discussions/3536#discussioncomment-2688984",
"storybook:build": "NODE_PATH=\"$PWD/node_modules\" storybook build -c ./storybook -o ./docs",
"storybook:dev": "NODE_PATH=\"$PWD/node_modules\" storybook dev -c ./storybook -p 50240",
"test": "jest tests/"
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/action-bar/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Remove unneeded `NODE_PATH` incorrectly copy-pasted from elsewhere. (Correct copy-pasting would have had it before the `webpack`, not before the `pnpm run clean`...)


4 changes: 2 additions & 2 deletions projects/packages/action-bar/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-action-bar",
"version": "0.1.20",
"version": "0.1.21-alpha",
"description": "An easy way for visitors to follow, like, and comment on your WordPress site.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/action-bar/#readme",
"bugs": {
Expand All @@ -15,7 +15,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build": "NODE_PATH=\"$PWD/node_modules\" pnpm run clean && webpack --config ./webpack.config.action-bar.js",
"build": "pnpm run clean && webpack --config ./webpack.config.action-bar.js",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build && pnpm run validate",
"clean": "rm -rf build/ .cache/",
"validate": "pnpm exec validate-es --no-error-on-unmatched-pattern build/",
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/blaze/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Remove unneeded `NODE_PATH` incorrectly copy-pasted from elsewhere. (Correct copy-pasting would have had it before the `webpack`, not before the `pnpm run clean`...)


4 changes: 2 additions & 2 deletions projects/packages/blaze/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-blaze",
"version": "0.7.1",
"version": "0.7.2-alpha",
"description": "Attract high-quality traffic to your site using Blaze. Using this service, you can advertise a post or page on some of the millions of pages across WordPress.com and Tumblr from just $5 per day.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/blaze/#readme",
"bugs": {
Expand All @@ -15,7 +15,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build": "NODE_PATH=\"$PWD/node_modules\" pnpm run clean && webpack",
"build": "pnpm run clean && webpack",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build && pnpm run validate",
"clean": "rm -rf build/ .cache/",
"validate": "pnpm exec validate-es --no-error-on-unmatched-pattern build/",
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/blaze/src/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Dashboard {
*
* @var string
*/
const PACKAGE_VERSION = '0.7.1';
const PACKAGE_VERSION = '0.7.2-alpha';

/**
* List of dependencies needed to render the dashboard in wp-admin.
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/forms/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Update postcss configs to use array syntax for plugins. No change to the project itself.


8 changes: 4 additions & 4 deletions projects/packages/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-forms",
"version": "0.19.5",
"version": "0.19.6-alpha",
"description": "Jetpack Forms",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/forms/#readme",
"bugs": {
Expand All @@ -17,9 +17,9 @@
"scripts": {
"build": "pnpm run clean && pnpm run build:blocks && pnpm run build:contact-form && pnpm run build:dashboard",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build && pnpm run validate",
"build:blocks": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.config.blocks.js",
"build:contact-form": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.config.contact-form.js",
"build:dashboard": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.config.dashboard.js",
"build:blocks": "webpack --config ./tools/webpack.config.blocks.js",
"build:contact-form": "webpack --config ./tools/webpack.config.contact-form.js",
"build:dashboard": "webpack --config ./tools/webpack.config.dashboard.js",
"clean": "rm -rf dist/ .cache/",
"test": "jest",
"validate": "pnpm exec validate-es --no-error-on-unmatched-pattern dist/",
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/forms/src/class-jetpack-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class Jetpack_Forms {

const PACKAGE_VERSION = '0.19.5';
const PACKAGE_VERSION = '0.19.6-alpha';

/**
* Load the contact form module.
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/forms/tools/webpack.config.blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const sharedWebpackConfig = {
loader: 'postcss-loader',
options: {
// postcssOptions: { config: path.join( __dirname, 'postcss.config.js' ) },
postcssOptions: { plugins: { autoprefixer: {} } },
postcssOptions: { plugins: [ require( 'autoprefixer' ) ] },
},
},
'sass-loader',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const sharedWebpackConfig = {
{
loader: 'postcss-loader',
options: {
postcssOptions: { plugins: { autoprefixer: {} } },
postcssOptions: { plugins: [ require( 'autoprefixer' ) ] },
},
},
{
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/publicize/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Update postcss configs to use array syntax for plugins. No change to the project itself.


7 changes: 3 additions & 4 deletions projects/packages/publicize/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-publicize",
"version": "0.30.2",
"version": "0.30.3-alpha",
"description": "Publicize makes it easy to share your site’s posts on several social media networks automatically when you publish a new post.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/publicize/#readme",
"bugs": {
Expand All @@ -16,13 +16,12 @@
"author": "Automattic",
"scripts": {
"build": "pnpm run clean && pnpm run build-client",
"//": "# We set NODE_PATH here so postcss-loader can find its plugins with pnpm 7. See https://github.com/pnpm/pnpm/discussions/3536#discussioncomment-2688984",
"build-client": "NODE_PATH=\"$PWD/node_modules\" webpack",
"build-client": "webpack",
"build-concurrently": "pnpm run clean && concurrently 'pnpm:build-client' 'pnpm:build-php'",
"build-production-concurrently": "pnpm run clean && concurrently 'NODE_ENV=production BABEL_ENV=production pnpm run build-client' && pnpm run validate",
"clean": "rm -rf build/",
"validate": "pnpm exec validate-es build/",
"watch": "pnpm run build && NODE_PATH=\"$PWD/node_modules\" webpack watch"
"watch": "pnpm run build && webpack watch"
},
"browserslist": [
"extends @wordpress/browserslist-config"
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/search/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Update postcss configs to use array syntax for plugins. No change to the project itself.


7 changes: 3 additions & 4 deletions projects/packages/search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetpack-search",
"version": "0.37.3",
"version": "0.37.4-alpha",
"description": "Package for Jetpack Search products",
"main": "main.js",
"directories": {
Expand All @@ -10,9 +10,8 @@
"build": "pnpm run clean && pnpm run build-instant && pnpm run build-customberg && pnpm run build-dashboard",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build && pnpm run validate",
"build-development": "NODE_ENV=development BABEL_ENV=development pnpm run build",
"//": "# We set NODE_PATH here so postcss-loader can find its plugins with pnpm 7. See https://github.com/pnpm/pnpm/discussions/3536#discussioncomment-2688984",
"build-instant": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.instant.config.js",
"build-customberg": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.customberg.config.js",
"build-instant": "webpack --config ./tools/webpack.instant.config.js",
"build-customberg": "webpack --config ./tools/webpack.customberg.config.js",
"build-dashboard": "webpack --config ./tools/webpack.dashboard.config.js",
"clean": "rm -rf build/ .cache/",
"test": "concurrently 'pnpm:test-scripts' 'pnpm:test-size'",
Expand Down
10 changes: 5 additions & 5 deletions projects/packages/search/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Uses Jetpack plugin's postcss config.
module.exports = () => ( {
plugins: {
'postcss-custom-properties': {
plugins: [
require( 'postcss-custom-properties' )( {
importFrom: [ require.resolve( '@automattic/calypso-color-schemes' ) ],
// @TODO: Drop `preserve: false` workaround if possible
// See https://github.com/Automattic/jetpack/pull/13854#issuecomment-550898168
preserve: false,
disableDeprecationNotice: true,
},
autoprefixer: {},
},
} ),
require( 'autoprefixer' ),
],
} );
2 changes: 1 addition & 1 deletion projects/packages/search/src/class-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Search package general information
*/
class Package {
const VERSION = '0.37.3';
const VERSION = '0.37.4-alpha';
const SLUG = 'search';

/**
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/videopress/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Update postcss configs to use array syntax for plugins. No change to the project itself.


4 changes: 2 additions & 2 deletions projects/packages/videopress/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-videopress",
"version": "0.14.7",
"version": "0.14.8-alpha",
"description": "VideoPress package",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/videopress/#readme",
"bugs": {
Expand All @@ -16,7 +16,7 @@
"author": "Automattic",
"scripts": {
"build": "pnpm run clean && pnpm run build-client",
"build-client": "NODE_PATH=\"$PWD/node_modules\" webpack",
"build-client": "webpack",
"clean": "rm -rf build/",
"validate": "pnpm exec validate-es build/",
"watch": "pnpm build && pnpm build-client --watch",
Expand Down
10 changes: 5 additions & 5 deletions projects/packages/videopress/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = () => ( {
plugins: {
'postcss-custom-properties': {
plugins: [
require( 'postcss-custom-properties' )( {
importFrom: [ require.resolve( '@automattic/calypso-color-schemes' ) ],
// Use of `preserve: false` dates back to when we still used @automattic/calypso-build.
// Ideally we'd get rid of it to properly make use of CSS vars, but first we have to
Expand All @@ -13,7 +13,7 @@ module.exports = () => ( {
// including a postcss.config.js like this by default.
preserve: false,
disableDeprecationNotice: true,
},
autoprefixer: {},
},
} ),
require( 'autoprefixer' ),
],
} );
2 changes: 1 addition & 1 deletion projects/packages/videopress/src/class-package-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* The Package_Version class.
*/
class Package_Version {
const PACKAGE_VERSION = '0.14.7';
const PACKAGE_VERSION = '0.14.8-alpha';

const PACKAGE_SLUG = 'videopress';

Expand Down
5 changes: 5 additions & 0 deletions projects/packages/wordads/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: removed
Comment: Remove unused postcss deps and config. No change to the package itself.


4 changes: 1 addition & 3 deletions projects/packages/wordads/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-wordads",
"version": "0.2.44",
"version": "0.2.45-alpha",
"description": "Earn income by allowing Jetpack to display high quality ads.",
"main": "main.js",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/wordads/#readme",
Expand Down Expand Up @@ -79,8 +79,6 @@
"core-js": "3.23.5",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"postcss": "8.4.21",
"postcss-loader": "6.2.0",
"prettier": "npm:[email protected]",
"sass": "1.43.3",
"sass-loader": "12.4.0",
Expand Down
13 changes: 0 additions & 13 deletions projects/packages/wordads/postcss.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion projects/packages/wordads/src/class-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* WordAds package general information
*/
class Package {
const VERSION = '0.2.44';
const VERSION = '0.2.45-alpha';
const SLUG = 'wordads';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Remove unneeded `NODE_PATH` incorrectly copy-pasted from elsewhere. (Correct copy-pasting would have had it before the `webpack`, not before the `pnpm run clean`...)


2 changes: 1 addition & 1 deletion projects/packages/yoast-promo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build": "NODE_PATH=\"$PWD/node_modules\" pnpm run clean && webpack",
"build": "pnpm run clean && webpack",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build && pnpm run validate",
"clean": "rm -rf build/ .cache/",
"validate": "pnpm exec validate-es --no-error-on-unmatched-pattern build/",
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/crm/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Update postcss configs to use array syntax for plugins. No change to the project itself.


4 changes: 2 additions & 2 deletions projects/plugins/crm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"license": "GPL-2.0",
"scripts": {
"build": "pnpm run clean && pnpm run build-client",
"build-client": "NODE_PATH=\"$PWD/node_modules\" webpack",
"build-client": "webpack",
"build-production": "NODE_ENV=production BABEL_ENV=production pnpm run build",
"clean": "rm -rf build css/*.map.css css/*.min.css* css/*.min.rtl.css css/*.rtl.css css/welcome-to-zbs/*.min.css* css/welcome-to-zbs/*.min.rtl.css js/*.min.js* js/welcome-to-zbs/wizard2.min.js*",
"test": "jest",
"watch": "pnpm run build && NODE_PATH=\"$PWD/node_modules\" webpack watch"
"watch": "pnpm run build && webpack watch"
},
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/jetpack/changelog/update-postcss-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Update postcss configs to use array syntax for plugins. No change to the project itself.


9 changes: 4 additions & 5 deletions projects/plugins/jetpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
"scripts": {
"build": "pnpm run clean && pnpm run build-client && pnpm run build-extensions && pnpm run build-widget-visibility && pnpm run build-asset-cdn-json",
"build-asset-cdn-json": "php tools/build-asset-cdn-json.php",
"//": "# We set NODE_PATH here (and in other 'build-' scripts) so postcss-loader can find its plugins with pnpm 7. See https://github.com/pnpm/pnpm/discussions/3536#discussioncomment-2688984",
"build-client": "NODE_PATH=\"$PWD/node_modules\" concurrently --names js,css,masterbar,module-headings 'webpack --config ./tools/webpack.config.js' 'webpack --config ./tools/webpack.config.css.js' 'webpack --config ./tools/webpack.config.masterbar.js' 'php tools/build-module-headings-translations.php'",
"build-client": "concurrently --names js,css,masterbar,module-headings 'webpack --config ./tools/webpack.config.js' 'webpack --config ./tools/webpack.config.css.js' 'webpack --config ./tools/webpack.config.masterbar.js' 'php tools/build-module-headings-translations.php'",
"build-concurrently": "pnpm run clean && concurrently 'pnpm:compile-ts' 'pnpm:build-client' 'pnpm:build-extensions' 'pnpm:build-widget-visibility' && pnpm run build-asset-cdn-json",
"build-extensions": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.config.extensions.js && tools/check-block-assets.php",
"build-extensions": "webpack --config ./tools/webpack.config.extensions.js && tools/check-block-assets.php",
"build-production": "pnpm run clean && pnpm run build-production-client && pnpm run build-production-extensions && pnpm run build-production-widget-visibility && pnpm run build-asset-cdn-json",
"build-production-concurrently": "pnpm run clean && concurrently 'pnpm:compile-ts' 'pnpm:build-production-client' 'pnpm:build-production-extensions' 'pnpm:build-production-widget-visibility' && pnpm run build-asset-cdn-json",
"build-production-client": "NODE_ENV=production BABEL_ENV=production pnpm run build-client && pnpm exec validate-es ./_inc/build/",
"build-production-extensions": "NODE_ENV=production BABEL_ENV=production pnpm run build-extensions && pnpm exec validate-es ./_inc/blocks",
"build-production-widget-visibility": "NODE_ENV=production BABEL_ENV=production pnpm run build-widget-visibility && pnpm exec validate-es ./_inc/build/widget-visibility/editor",
"build-widget-visibility": "NODE_PATH=\"$PWD/node_modules\" webpack --config ./tools/webpack.config.widget-visibility.js",
"build-widget-visibility": "webpack --config ./tools/webpack.config.widget-visibility.js",
"clean": "pnpm run clean-client && pnpm run clean-extensions",
"clean-client": "rm -rf _inc/build/ css/",
"clean-extensions": "rm -rf _inc/blocks/ ",
Expand All @@ -38,7 +37,7 @@
"test-client": "NODE_PATH=tests:_inc/client jest --config=tests/jest.config.client.js",
"test-extensions": "TZ=UTC jest --config=tests/jest.config.extensions.js",
"test-gui": "NODE_PATH=tests:_inc/client jest --config=tests/jest.config.gui.js",
"watch": "NODE_PATH=\"$PWD/node_modules\" concurrently --names client-js,client-css,masterbar,extensions,widget-visibility 'webpack watch --config ./tools/webpack.config.js' 'webpack watch --config ./tools/webpack.config.css.js' 'webpack watch --config ./tools/webpack.config.masterbar.js' 'webpack watch --config ./tools/webpack.config.extensions.js' 'webpack watch --config ./tools/webpack.config.widget-visibility.js'"
"watch": "concurrently --names client-js,client-css,masterbar,extensions,widget-visibility 'webpack watch --config ./tools/webpack.config.js' 'webpack watch --config ./tools/webpack.config.css.js' 'webpack watch --config ./tools/webpack.config.masterbar.js' 'webpack watch --config ./tools/webpack.config.extensions.js' 'webpack watch --config ./tools/webpack.config.widget-visibility.js'"
},
"browserslist": [
"extends @wordpress/browserslist-config"
Expand Down
Loading

0 comments on commit abe75af

Please sign in to comment.