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.
|
|
|
|
// If a block is experimental, it should be marked with the `isExperimental`
|
|
|
|
// property.
|
|
|
|
const blocks = {
|
2023-01-12 07:34:45 +00:00
|
|
|
'active-filters': {},
|
2023-02-16 10:43:37 +00:00
|
|
|
'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-12 07:34:45 +00:00
|
|
|
cart: {},
|
2023-01-17 15:20:10 +00:00
|
|
|
'catalog-sorting': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
checkout: {},
|
|
|
|
'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': {},
|
2022-04-08 08:51:21 +00:00
|
|
|
'mini-cart': {},
|
2021-11-19 11:47:48 +00:00
|
|
|
'mini-cart-contents': {
|
2022-04-07 13:47:58 +00:00
|
|
|
customDir: 'mini-cart/mini-cart-contents',
|
2021-11-19 11:47:48 +00:00
|
|
|
},
|
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-07-03 14:21:31 +00:00
|
|
|
'product-gallery': {
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
2023-07-06 15:08:39 +00:00
|
|
|
'product-gallery-large-image': {
|
|
|
|
customDir: 'product-gallery/inner-blocks/product-gallery-large-image',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
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-09-19 21:37:00 +00:00
|
|
|
isExperimental: true,
|
2023-08-28 16:32:45 +00:00
|
|
|
},
|
2023-08-22 19:26:46 +00:00
|
|
|
'product-gallery-pager': {
|
|
|
|
customDir: 'product-gallery/inner-blocks/product-gallery-pager',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
2023-08-02 07:09:51 +00:00
|
|
|
'product-gallery-thumbnails': {
|
|
|
|
customDir: 'product-gallery/inner-blocks/product-gallery-thumbnails',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
2023-01-12 07:34:45 +00:00
|
|
|
'product-new': {},
|
|
|
|
'product-on-sale': {},
|
|
|
|
'product-query': {
|
2020-07-22 12:05:56 +00:00
|
|
|
isExperimental: true,
|
|
|
|
},
|
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-10-12 04:30:27 +00:00
|
|
|
'collection-price-filter': {
|
|
|
|
customDir: 'collection-filters/inner-blocks/price-filter',
|
|
|
|
isExperimental: true,
|
|
|
|
},
|
2023-06-05 12:11:21 +00:00
|
|
|
'single-product': {},
|
2023-01-12 07:34:45 +00:00
|
|
|
'stock-filter': {},
|
2023-09-14 04:13:33 +00:00
|
|
|
'collection-filters': {
|
|
|
|
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',
|
|
|
|
},
|
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.
|
|
|
|
const getBlockEntries = ( relativePath ) => {
|
|
|
|
const experimental =
|
|
|
|
! parseInt( process.env.WOOCOMMERCE_BLOCKS_PHASE, 10 ) < 3;
|
|
|
|
|
|
|
|
return Object.fromEntries(
|
|
|
|
Object.entries( blocks )
|
|
|
|
.filter(
|
|
|
|
( [ , config ] ) =>
|
|
|
|
! config.isExperimental ||
|
|
|
|
config.isExperimental === experimental
|
|
|
|
)
|
|
|
|
.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
|
|
|
|
'packages-style': glob.sync( './packages/**/index.js' ),
|
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',
|
2023-07-20 12:28:15 +00:00
|
|
|
'add-to-cart-form':
|
|
|
|
'./assets/js/atomic/blocks/product-elements/add-to-cart-form/index.tsx',
|
2023-07-04 11:06:48 +00:00
|
|
|
...getBlockEntries( '{index,block,frontend}.{t,j}s{,x}' ),
|
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',
|
2021-01-11 12:12:26 +00:00
|
|
|
blocksCheckout: './packages/checkout/index.js',
|
2023-10-17 09:47:34 +00:00
|
|
|
blocksComponents: './packages/components/index.js',
|
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
|
2021-06-09 14:09:42 +00:00
|
|
|
...getBlockEntries( 'index.{t,j}s{,x}' ),
|
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}' ),
|
2021-08-25 15:42:55 +00:00
|
|
|
'mini-cart-component':
|
2022-04-07 13:47:58 +00:00
|
|
|
'./assets/js/blocks/mini-cart/component-frontend.tsx',
|
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',
|
|
|
|
},
|
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,
|
|
|
|
};
|