From 6df879a922d54510890b9fc2b420872719bfb212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Tue, 31 Mar 2020 12:46:38 +0200 Subject: [PATCH] Load product grid styles in WP <=5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2000) * Load product grid styles in WP <=5.2 * Explicitly exclude 'product-list-style' from default builds --- plugins/woocommerce-blocks/bin/webpack-helpers.js | 6 ++++++ plugins/woocommerce-blocks/webpack.config.js | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-blocks/bin/webpack-helpers.js b/plugins/woocommerce-blocks/bin/webpack-helpers.js index 2ae9ad47cd3..2f0d7c5c0c1 100644 --- a/plugins/woocommerce-blocks/bin/webpack-helpers.js +++ b/plugins/woocommerce-blocks/bin/webpack-helpers.js @@ -115,6 +115,12 @@ const stableMainEntry = { 'snackbar-notice-style': './node_modules/wordpress-components/src/snackbar/style.scss', + // Styles for grid blocks. WP <=5.2 doesn't have the All Products block, + // so this file would not be included if not explicitly declared here. + // This file is excluded from the default build so CSS styles are included + // in the other the components are imported. + 'product-list-style': './assets/js/base/components/product-list/style.scss', + // Blocks 'handpicked-products': './assets/js/blocks/handpicked-products/index.js', 'product-best-sellers': './assets/js/blocks/product-best-sellers/index.js', diff --git a/plugins/woocommerce-blocks/webpack.config.js b/plugins/woocommerce-blocks/webpack.config.js index 787f604ad52..72f5f699ed7 100644 --- a/plugins/woocommerce-blocks/webpack.config.js +++ b/plugins/woocommerce-blocks/webpack.config.js @@ -108,7 +108,14 @@ const CoreConfig = { const GutenbergBlocksConfig = { ...baseConfig, - ...getMainConfig( { alias: getAlias() } ), + ...getMainConfig( { + alias: getAlias(), + // This file is already imported by the All Products dependencies, + // so we can safely exclude it from the default build. It's still + // needed in the legacy build because it doesn't include the + // All Products block. + exclude: [ 'product-list-style' ], + } ), }; const BlocksFrontendConfig = {