2020-07-07 09:05:06 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
const { omit } = require( 'lodash' );
|
2020-07-22 12:05:56 +00:00
|
|
|
const glob = require( 'glob' );
|
2020-07-07 09:05:06 +00:00
|
|
|
|
2020-07-22 12:05:56 +00:00
|
|
|
// List of blocks that should be used as webpack entry points. They are expected
|
|
|
|
// to be in `/assets/js/blocks/[BLOCK_NAME]`. If they are not, their relative
|
|
|
|
// path should be defined in the `customDir` property. The scripts below will
|
|
|
|
// take care of looking for `index.js`, `frontend.js` and `*.scss` files in each
|
|
|
|
// block directory.
|
2024-06-10 13:12:10 +00:00
|
|
|
//
|
2020-07-22 12:05:56 +00:00
|
|
|
// If a block is experimental, it should be marked with the `isExperimental`
|
|
|
|
// property.
|
2024-06-10 13:12:10 +00:00
|
|
|
// Update plugins/woocommerce-blocks/docs/internal-developers/blocks/feature-flags-and-experimental-interfaces.md
|
|
|
|
// when you mark/unmark block experimental.
|
2020-07-22 12:05:56 +00:00
|
|
|
const blocks = {
|
2023-01-12 07:34:45 +00:00
|
|
|
'active-filters': {},
|
2024-10-10 14:36:49 +00:00
|
|
|
'add-to-cart-form': {
|
|
|
|
customDir: 'product-elements/add-to-cart-form',
|
|
|
|
},
|
2023-01-12 07:34:45 +00:00
|
|
|
'all-products': {
|
|
|
|
customDir: 'products/all-products',
|
2022-05-19 16:16:46 +00:00
|
|
|
},
|
2020-07-22 12:05:56 +00:00
|
|
|
'all-reviews': {
|
|
|
|
customDir: 'reviews/all-reviews',
|
2020-07-07 09:05:06 +00:00
|
|
|
},
|
2023-01-12 07:34:45 +00:00
|
|
|
'attribute-filter': {},
|
2023-01-27 17:31:13 +00:00
|
|
|
breadcrumbs: {},
|
2023-01-17 15:20:10 +00:00
|
|
|
'catalog-sorting': {},
|
2024-04-23 04:07:56 +00:00
|
|
|
'coming-soon': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'customer-account': {},
|
2022-05-19 16:16:46 +00:00
|
|
|
'featured-category': {
|
|
|
|
customDir: 'featured-items/featured-category',
|
|
|
|
},
|
2023-01-12 07:34:45 +00:00
|
|
|
'featured-product': {
|
|
|
|
customDir: 'featured-items/featured-product',
|
|
|
|
},
|
|
|
|
'filter-wrapper': {},
|
|
|
|
'handpicked-products': {},
|
|
|
|
// We need to keep the legacy-template id, so we need to add a custom config to point to the renamed classic-template folder
|
|
|
|
'legacy-template': {
|
|
|
|
customDir: 'classic-template',
|
2020-07-22 12:05:56 +00:00
|
|
|
},
|
2023-09-19 09:58:18 +00:00
|
|
|
'classic-shortcode': {},
|
2023-01-18 12:40:30 +00:00
|
|
|
'store-notices': {},
|
2023-09-19 09:58:18 +00:00
|
|
|
'page-content-wrapper': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'price-filter': {},
|
|
|
|
'product-best-sellers': {},
|
|
|
|
'product-category': {},
|
|
|
|
'product-categories': {},
|
2023-08-25 13:58:11 +00:00
|
|
|
'product-collection': {},
|
2023-11-20 13:18:59 +00:00
|
|
|
'product-collection-no-results': {
|
|
|
|
customDir: 'product-collection/inner-blocks/no-results',
|
|
|
|
},
|
2024-01-17 00:05:47 +00:00
|
|
|
'product-gallery': {},
|
2023-07-06 15:08:39 +00:00
|
|
|
'product-gallery-large-image': {
|
|
|
|
customDir: 'product-gallery/inner-blocks/product-gallery-large-image',
|
|
|
|
},
|
2023-08-28 16:32:45 +00:00
|
|
|
'product-gallery-large-image-next-previous': {
|
|
|
|
customDir:
|
|
|
|
'product-gallery/inner-blocks/product-gallery-large-image-next-previous',
|
|
|
|
},
|
2023-08-22 19:26:46 +00:00
|
|
|
'product-gallery-pager': {
|
|
|
|
customDir: 'product-gallery/inner-blocks/product-gallery-pager',
|
|
|
|
},
|
2023-08-02 07:09:51 +00:00
|
|
|
'product-gallery-thumbnails': {
|
|
|
|
customDir: 'product-gallery/inner-blocks/product-gallery-thumbnails',
|
|
|
|
},
|
2023-01-12 07:34:45 +00:00
|
|
|
'product-new': {},
|
|
|
|
'product-on-sale': {},
|
2023-11-24 07:36:30 +00:00
|
|
|
'product-query': {},
|
2023-01-17 15:19:42 +00:00
|
|
|
'product-results-count': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'product-search': {},
|
|
|
|
'product-tag': {},
|
2023-08-25 13:58:11 +00:00
|
|
|
'product-template': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'product-top-rated': {},
|
|
|
|
'products-by-attribute': {},
|
|
|
|
'rating-filter': {},
|
2023-07-24 09:02:24 +00:00
|
|
|
'product-average-rating': {},
|
|
|
|
'product-rating-stars': {},
|
|
|
|
'product-rating-counter': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'reviews-by-category': {
|
|
|
|
customDir: 'reviews/reviews-by-category',
|
2022-03-22 22:34:43 +00:00
|
|
|
},
|
2023-01-12 07:34:45 +00:00
|
|
|
'reviews-by-product': {
|
|
|
|
customDir: 'reviews/reviews-by-product',
|
|
|
|
},
|
2023-06-05 12:11:21 +00:00
|
|
|
'single-product': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'stock-filter': {},
|
2024-08-29 15:23:40 +00:00
|
|
|
'product-filters': {
|
2023-09-14 04:13:33 +00:00
|
|
|
isExperimental: true,
|
|
|
|
},
|
2024-06-19 19:11:51 +00:00
|
|
|
'product-filters-overlay': {
|
|
|
|
isExperimental: true,
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/overlay',
|
2024-06-19 19:11:51 +00:00
|
|
|
},
|
2024-06-28 08:16:21 +00:00
|
|
|
'product-filters-overlay-navigation': {
|
|
|
|
isExperimental: true,
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/overlay-navigation',
|
2024-06-28 08:16:21 +00:00
|
|
|
},
|
2024-10-24 17:16:54 +00:00
|
|
|
'product-filter-status': {
|
2023-11-15 03:50:05 +00:00
|
|
|
isExperimental: true,
|
2024-10-24 17:16:54 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/status-filter',
|
2023-11-15 03:50:05 +00:00
|
|
|
},
|
2024-01-23 05:29:24 +00:00
|
|
|
'product-filter-price': {
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/price-filter',
|
2023-11-07 07:55:23 +00:00
|
|
|
isExperimental: true,
|
|
|
|
},
|
2024-01-23 05:29:24 +00:00
|
|
|
'product-filter-attribute': {
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/attribute-filter',
|
2023-11-21 07:22:20 +00:00
|
|
|
isExperimental: true,
|
|
|
|
},
|
2024-01-23 05:29:24 +00:00
|
|
|
'product-filter-rating': {
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/rating-filter',
|
2023-12-18 09:47:24 +00:00
|
|
|
isExperimental: true,
|
|
|
|
},
|
2024-01-23 05:29:24 +00:00
|
|
|
'product-filter-active': {
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/active-filters',
|
2023-12-19 10:29:33 +00:00
|
|
|
isExperimental: true,
|
2024-05-13 18:19:56 +00:00
|
|
|
},
|
|
|
|
'product-filter-clear-button': {
|
2024-08-29 15:23:40 +00:00
|
|
|
customDir: 'product-filters/inner-blocks/clear-button',
|
2024-05-13 18:19:56 +00:00
|
|
|
isExperimental: true,
|
2023-12-19 10:29:33 +00:00
|
|
|
},
|
2024-09-13 17:04:06 +00:00
|
|
|
'product-filter-checkbox-list': {
|
|
|
|
customDir: 'product-filters/inner-blocks/checkbox-list',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
|
|
|
'product-filter-chips': {
|
|
|
|
customDir: 'product-filters/inner-blocks/chips',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
2023-09-20 12:56:00 +00:00
|
|
|
'order-confirmation-summary': {
|
|
|
|
customDir: 'order-confirmation/summary',
|
|
|
|
},
|
|
|
|
'order-confirmation-totals-wrapper': {
|
|
|
|
customDir: 'order-confirmation/totals-wrapper',
|
|
|
|
},
|
|
|
|
'order-confirmation-totals': {
|
|
|
|
customDir: 'order-confirmation/totals',
|
|
|
|
},
|
|
|
|
'order-confirmation-downloads-wrapper': {
|
|
|
|
customDir: 'order-confirmation/downloads-wrapper',
|
|
|
|
},
|
|
|
|
'order-confirmation-downloads': {
|
|
|
|
customDir: 'order-confirmation/downloads',
|
|
|
|
},
|
|
|
|
'order-confirmation-billing-address': {
|
|
|
|
customDir: 'order-confirmation/billing-address',
|
|
|
|
},
|
|
|
|
'order-confirmation-shipping-address': {
|
|
|
|
customDir: 'order-confirmation/shipping-address',
|
|
|
|
},
|
|
|
|
'order-confirmation-billing-wrapper': {
|
|
|
|
customDir: 'order-confirmation/billing-wrapper',
|
|
|
|
},
|
|
|
|
'order-confirmation-shipping-wrapper': {
|
|
|
|
customDir: 'order-confirmation/shipping-wrapper',
|
|
|
|
},
|
|
|
|
'order-confirmation-status': {
|
|
|
|
customDir: 'order-confirmation/status',
|
|
|
|
},
|
|
|
|
'order-confirmation-additional-information': {
|
|
|
|
customDir: 'order-confirmation/additional-information',
|
|
|
|
},
|
2024-01-16 13:17:28 +00:00
|
|
|
'order-confirmation-additional-fields-wrapper': {
|
|
|
|
customDir: 'order-confirmation/additional-fields-wrapper',
|
|
|
|
},
|
|
|
|
'order-confirmation-additional-fields': {
|
|
|
|
customDir: 'order-confirmation/additional-fields',
|
|
|
|
},
|
2024-09-12 10:18:13 +00:00
|
|
|
'order-confirmation-create-account': {
|
|
|
|
customDir: 'order-confirmation/create-account',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
2020-07-22 12:05:56 +00:00
|
|
|
};
|
|
|
|
|
2024-07-10 09:23:17 +00:00
|
|
|
// Intentional separation of cart and checkout entry points to allow for better code splitting.
|
|
|
|
const cartAndCheckoutBlocks = {
|
|
|
|
cart: {},
|
2024-10-17 15:50:12 +00:00
|
|
|
'cart-link': {},
|
2024-07-10 09:23:17 +00:00
|
|
|
checkout: {},
|
|
|
|
'mini-cart': {},
|
|
|
|
'mini-cart-contents': {
|
|
|
|
customDir: 'mini-cart/mini-cart-contents',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-07-22 12:05:56 +00:00
|
|
|
// Returns the entries for each block given a relative path (ie: `index.js`,
|
|
|
|
// `**/*.scss`...).
|
|
|
|
// It also filters out elements with undefined props and experimental blocks.
|
2024-07-10 09:23:17 +00:00
|
|
|
const getBlockEntries = ( relativePath, blockEntries = blocks ) => {
|
2020-07-22 12:05:56 +00:00
|
|
|
return Object.fromEntries(
|
2024-07-10 09:23:17 +00:00
|
|
|
Object.entries( blockEntries )
|
2020-07-22 12:05:56 +00:00
|
|
|
.map( ( [ blockCode, config ] ) => {
|
|
|
|
const filePaths = glob.sync(
|
|
|
|
`./assets/js/blocks/${ config.customDir || blockCode }/` +
|
|
|
|
relativePath
|
|
|
|
);
|
|
|
|
if ( filePaths.length > 0 ) {
|
|
|
|
return [ blockCode, filePaths ];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
} )
|
|
|
|
.filter( Boolean )
|
|
|
|
);
|
|
|
|
};
|
2020-07-07 09:05:06 +00:00
|
|
|
|
2020-07-22 12:05:56 +00:00
|
|
|
const entries = {
|
|
|
|
styling: {
|
2023-07-04 11:06:48 +00:00
|
|
|
// Packages styles
|
2023-10-23 14:59:19 +00:00
|
|
|
'packages-style': glob.sync( './packages/**/index.{t,j}s' ),
|
2020-07-07 09:05:06 +00:00
|
|
|
|
2023-07-04 11:06:48 +00:00
|
|
|
// Shared blocks code
|
|
|
|
'wc-blocks': './assets/js/index.js',
|
2021-01-07 12:02:21 +00:00
|
|
|
|
2023-07-04 11:06:48 +00:00
|
|
|
// Blocks
|
|
|
|
'product-image-gallery':
|
|
|
|
'./assets/js/atomic/blocks/product-elements/product-image-gallery/index.ts',
|
|
|
|
'product-reviews':
|
|
|
|
'./assets/js/atomic/blocks/product-elements/product-reviews/index.tsx',
|
|
|
|
'product-details':
|
|
|
|
'./assets/js/atomic/blocks/product-elements/product-details/index.tsx',
|
2024-07-10 09:23:17 +00:00
|
|
|
...getBlockEntries( '{index,block,frontend}.{t,j}s{,x}', {
|
|
|
|
...blocks,
|
|
|
|
...cartAndCheckoutBlocks,
|
|
|
|
} ),
|
2023-07-31 07:03:10 +00:00
|
|
|
|
2023-12-18 09:47:24 +00:00
|
|
|
// Interactivity component styling
|
|
|
|
'wc-interactivity-checkbox-list':
|
|
|
|
'./packages/interactivity-components/checkbox-list/index.ts',
|
|
|
|
'wc-interactivity-dropdown':
|
|
|
|
'./packages/interactivity-components/dropdown/index.ts',
|
|
|
|
|
2023-07-31 07:03:10 +00:00
|
|
|
// Templates
|
|
|
|
'wc-blocks-classic-template-revert-button-style':
|
|
|
|
'./assets/js/templates/revert-button/index.tsx',
|
2020-07-22 12:05:56 +00:00
|
|
|
},
|
|
|
|
core: {
|
|
|
|
wcBlocksRegistry: './assets/js/blocks-registry/index.js',
|
2021-04-22 11:37:27 +00:00
|
|
|
wcSettings: './assets/js/settings/shared/index.ts',
|
2021-08-13 13:28:41 +00:00
|
|
|
wcBlocksData: './assets/js/data/index.ts',
|
2020-07-22 12:05:56 +00:00
|
|
|
wcBlocksMiddleware: './assets/js/middleware/index.js',
|
2021-06-09 14:09:42 +00:00
|
|
|
wcBlocksSharedContext: './assets/js/shared/context/index.js',
|
|
|
|
wcBlocksSharedHocs: './assets/js/shared/hocs/index.js',
|
2021-02-04 15:30:28 +00:00
|
|
|
priceFormat: './packages/prices/index.js',
|
2024-04-23 08:18:37 +00:00
|
|
|
wcTypes: './assets/js/types/index.ts',
|
2023-11-15 03:50:05 +00:00
|
|
|
|
|
|
|
// interactivity components, exported as separate entries for now
|
|
|
|
'wc-interactivity-dropdown':
|
|
|
|
'./packages/interactivity-components/dropdown/index.ts',
|
2023-12-18 09:47:24 +00:00
|
|
|
'wc-interactivity-checkbox-list':
|
|
|
|
'./packages/interactivity-components/checkbox-list/index.ts',
|
2020-07-22 12:05:56 +00:00
|
|
|
},
|
|
|
|
main: {
|
|
|
|
// Shared blocks code
|
2021-06-09 14:09:42 +00:00
|
|
|
'wc-blocks': './assets/js/index.js',
|
2020-07-07 09:05:06 +00:00
|
|
|
|
|
|
|
// Blocks
|
2024-07-10 09:23:17 +00:00
|
|
|
...getBlockEntries( 'index.{t,j}s{,x}', {
|
|
|
|
...blocks,
|
|
|
|
...cartAndCheckoutBlocks,
|
|
|
|
} ),
|
2020-07-07 09:05:06 +00:00
|
|
|
},
|
|
|
|
frontend: {
|
2023-09-20 04:21:26 +00:00
|
|
|
reviews: './assets/js/blocks/reviews/frontend.ts',
|
2021-06-09 14:09:42 +00:00
|
|
|
...getBlockEntries( 'frontend.{t,j}s{,x}' ),
|
2023-08-10 14:02:33 +00:00
|
|
|
'product-button-interactivity':
|
|
|
|
'./assets/js/atomic/blocks/product-elements/button/frontend.tsx',
|
2020-07-07 09:05:06 +00:00
|
|
|
},
|
|
|
|
payments: {
|
|
|
|
'wc-payment-method-cheque':
|
2022-11-11 16:17:49 +00:00
|
|
|
'./assets/js/extensions/payment-methods/cheque/index.js',
|
2020-07-07 09:05:06 +00:00
|
|
|
'wc-payment-method-paypal':
|
2022-11-11 16:17:49 +00:00
|
|
|
'./assets/js/extensions/payment-methods/paypal/index.js',
|
2020-07-08 00:39:16 +00:00
|
|
|
'wc-payment-method-bacs':
|
2022-11-11 16:17:49 +00:00
|
|
|
'./assets/js/extensions/payment-methods/bacs/index.js',
|
2020-07-15 14:14:41 +00:00
|
|
|
'wc-payment-method-cod':
|
2022-11-11 16:17:49 +00:00
|
|
|
'./assets/js/extensions/payment-methods/cod/index.js',
|
2020-07-07 09:05:06 +00:00
|
|
|
},
|
2021-03-16 11:40:22 +00:00
|
|
|
extensions: {
|
|
|
|
'wc-blocks-google-analytics':
|
|
|
|
'./assets/js/extensions/google-analytics/index.ts',
|
2022-11-11 16:17:49 +00:00
|
|
|
'wc-shipping-method-pickup-location':
|
|
|
|
'./assets/js/extensions/shipping-methods/pickup-location/index.js',
|
2021-03-16 11:40:22 +00:00
|
|
|
},
|
2023-07-31 07:03:10 +00:00
|
|
|
editor: {
|
|
|
|
'wc-blocks-classic-template-revert-button':
|
|
|
|
'./assets/js/templates/revert-button/index.tsx',
|
|
|
|
},
|
2024-07-10 09:23:17 +00:00
|
|
|
cartAndCheckoutFrontend: {
|
|
|
|
...getBlockEntries( 'frontend.{t,j}s{,x}', cartAndCheckoutBlocks ),
|
|
|
|
blocksCheckout: './packages/checkout/index.js',
|
|
|
|
blocksComponents: './packages/components/index.ts',
|
|
|
|
'mini-cart-component':
|
|
|
|
'./assets/js/blocks/mini-cart/component-frontend.tsx',
|
|
|
|
},
|
2020-07-07 09:05:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const getEntryConfig = ( type = 'main', exclude = [] ) => {
|
2020-07-22 12:05:56 +00:00
|
|
|
return omit( entries[ type ], exclude );
|
2020-07-07 09:05:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getEntryConfig,
|
|
|
|
};
|