2018-11-13 19:12:32 +00:00
|
|
|
/**
|
2020-07-07 09:05:06 +00:00
|
|
|
* Internal dependencies
|
2018-11-13 19:12:32 +00:00
|
|
|
*/
|
2019-10-06 12:36:15 +00:00
|
|
|
const FallbackModuleDirectoryPlugin = require( './bin/fallback-module-directory-webpack-plugin' );
|
2020-07-07 09:05:06 +00:00
|
|
|
const { NODE_ENV, FORCE_MAP, getAlias } = require( './bin/webpack-helpers.js' );
|
2019-10-06 12:36:15 +00:00
|
|
|
const {
|
2020-07-07 09:05:06 +00:00
|
|
|
getCoreConfig,
|
2019-10-06 12:36:15 +00:00
|
|
|
getMainConfig,
|
|
|
|
getFrontConfig,
|
2020-07-07 09:05:06 +00:00
|
|
|
getPaymentsConfig,
|
|
|
|
} = require( './bin/webpack-configs.js' );
|
2019-02-19 21:09:36 +00:00
|
|
|
|
2020-07-07 09:05:06 +00:00
|
|
|
// Only options shared between all configs should be defined here.
|
|
|
|
const sharedConfig = {
|
2019-07-22 09:39:00 +00:00
|
|
|
mode: NODE_ENV,
|
|
|
|
performance: {
|
|
|
|
hints: false,
|
|
|
|
},
|
|
|
|
stats: {
|
|
|
|
all: false,
|
|
|
|
assets: true,
|
|
|
|
builtAt: true,
|
|
|
|
colors: true,
|
|
|
|
errors: true,
|
|
|
|
hash: true,
|
|
|
|
timings: true,
|
|
|
|
},
|
2019-10-28 11:00:04 +00:00
|
|
|
watchOptions: {
|
|
|
|
ignored: /node_modules/,
|
|
|
|
},
|
2020-04-06 09:00:47 +00:00
|
|
|
devtool: NODE_ENV === 'development' || FORCE_MAP ? 'source-map' : false,
|
2019-08-22 20:56:47 +00:00
|
|
|
};
|
|
|
|
|
2020-07-07 09:05:06 +00:00
|
|
|
// Core config for shared libraries.
|
2019-08-22 20:56:47 +00:00
|
|
|
const CoreConfig = {
|
2020-07-07 09:05:06 +00:00
|
|
|
...sharedConfig,
|
|
|
|
...getCoreConfig( { alias: getAlias() } ),
|
2019-07-22 09:39:00 +00:00
|
|
|
};
|
|
|
|
|
2020-07-07 09:05:06 +00:00
|
|
|
// Main Blocks config for registering Blocks and for the Editor.
|
|
|
|
const MainConfig = {
|
|
|
|
...sharedConfig,
|
2020-03-31 10:46:38 +00:00
|
|
|
...getMainConfig( {
|
|
|
|
alias: getAlias(),
|
2020-07-07 09:05:06 +00:00
|
|
|
// 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.
|
2020-03-31 10:46:38 +00:00
|
|
|
exclude: [ 'product-list-style' ],
|
|
|
|
} ),
|
2019-10-06 12:36:15 +00:00
|
|
|
};
|
|
|
|
|
2020-07-07 09:05:06 +00:00
|
|
|
// Frontend config for scripts used in the store itself.
|
|
|
|
const FrontendConfig = {
|
|
|
|
...sharedConfig,
|
2019-10-28 13:53:09 +00:00
|
|
|
...getFrontConfig( { alias: getAlias() } ),
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-07-07 09:05:06 +00:00
|
|
|
* This is a temporary config for building the payment methods integration script until it can be
|
|
|
|
* moved into the payment extension(s).
|
2019-10-28 13:53:09 +00:00
|
|
|
*/
|
2020-07-07 09:05:06 +00:00
|
|
|
const PaymentsConfig = {
|
|
|
|
...sharedConfig,
|
|
|
|
...getPaymentsConfig( { alias: getAlias() } ),
|
|
|
|
};
|
2019-10-28 13:53:09 +00:00
|
|
|
|
2020-07-07 09:05:06 +00:00
|
|
|
/**
|
|
|
|
* Legacy Configs are for builds targeting < WP5.3 and handle backwards compatibility and disabling
|
|
|
|
* unsupported features.
|
|
|
|
*/
|
|
|
|
const LegacyMainConfig = {
|
|
|
|
...sharedConfig,
|
2019-10-06 12:36:15 +00:00
|
|
|
...getMainConfig( {
|
|
|
|
fileSuffix: 'legacy',
|
|
|
|
resolvePlugins: [
|
|
|
|
new FallbackModuleDirectoryPlugin(
|
|
|
|
'/legacy/',
|
|
|
|
'/',
|
|
|
|
getAlias( { pathPart: 'legacy' } )
|
|
|
|
),
|
2018-11-13 19:21:04 +00:00
|
|
|
],
|
2019-11-15 14:41:23 +00:00
|
|
|
exclude: [
|
|
|
|
'all-products',
|
|
|
|
'price-filter',
|
|
|
|
'attribute-filter',
|
|
|
|
'active-filters',
|
2019-12-09 20:50:49 +00:00
|
|
|
'checkout',
|
|
|
|
'cart',
|
2020-05-27 14:45:18 +00:00
|
|
|
'single-product',
|
2019-11-15 14:41:23 +00:00
|
|
|
],
|
2019-10-06 12:36:15 +00:00
|
|
|
} ),
|
2019-07-22 09:39:00 +00:00
|
|
|
};
|
|
|
|
|
2020-07-07 09:05:06 +00:00
|
|
|
const LegacyFrontendConfig = {
|
|
|
|
...sharedConfig,
|
2019-10-06 12:36:15 +00:00
|
|
|
...getFrontConfig( {
|
|
|
|
fileSuffix: 'legacy',
|
|
|
|
resolvePlugins: [
|
|
|
|
new FallbackModuleDirectoryPlugin(
|
|
|
|
'/legacy/',
|
|
|
|
'/',
|
|
|
|
getAlias( { pathPart: 'legacy' } )
|
|
|
|
),
|
2019-07-22 09:39:00 +00:00
|
|
|
],
|
2019-11-15 14:41:23 +00:00
|
|
|
exclude: [
|
|
|
|
'all-products',
|
|
|
|
'price-filter',
|
|
|
|
'attribute-filter',
|
|
|
|
'active-filters',
|
2019-12-09 20:50:49 +00:00
|
|
|
'checkout',
|
|
|
|
'cart',
|
2020-05-27 14:45:18 +00:00
|
|
|
'single-product',
|
2019-11-15 14:41:23 +00:00
|
|
|
],
|
2019-10-06 12:36:15 +00:00
|
|
|
} ),
|
2018-02-13 19:03:53 +00:00
|
|
|
};
|
|
|
|
|
2019-10-06 12:36:15 +00:00
|
|
|
module.exports = [
|
|
|
|
CoreConfig,
|
2020-07-07 09:05:06 +00:00
|
|
|
MainConfig,
|
|
|
|
FrontendConfig,
|
|
|
|
PaymentsConfig,
|
|
|
|
LegacyMainConfig,
|
|
|
|
LegacyFrontendConfig,
|
2019-10-06 12:36:15 +00:00
|
|
|
];
|