2020-02-24 02:25:26 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2020-04-29 17:03:20 +00:00
|
|
|
const path = require( 'path' );
|
2021-06-02 03:54:00 +00:00
|
|
|
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
|
2024-06-13 05:05:28 +00:00
|
|
|
const webpack = require( 'webpack' );
|
2020-02-24 02:25:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-04-27 21:54:54 +00:00
|
|
|
const wcAdminWebpackConfig = require( '../../plugins/woocommerce-admin/webpack.config.js' );
|
2020-02-24 02:25:26 +00:00
|
|
|
|
2020-04-29 17:03:20 +00:00
|
|
|
const wcAdminPackages = [
|
|
|
|
'components',
|
|
|
|
'csv-export',
|
|
|
|
'currency',
|
|
|
|
'date',
|
|
|
|
'navigation',
|
|
|
|
'number',
|
|
|
|
'data',
|
2020-08-20 04:59:52 +00:00
|
|
|
'tracks',
|
2021-05-14 15:23:01 +00:00
|
|
|
'experimental',
|
2020-04-29 17:03:20 +00:00
|
|
|
];
|
|
|
|
|
2021-06-02 03:54:00 +00:00
|
|
|
module.exports = ( storybookConfig ) => {
|
2022-03-29 06:57:04 +00:00
|
|
|
storybookConfig.module.rules = [
|
|
|
|
...storybookConfig.module.rules,
|
|
|
|
...wcAdminWebpackConfig.module.rules,
|
|
|
|
];
|
2020-02-24 02:25:26 +00:00
|
|
|
|
|
|
|
storybookConfig.resolve.alias = wcAdminWebpackConfig.resolve.alias;
|
|
|
|
|
2020-04-29 17:03:20 +00:00
|
|
|
wcAdminPackages.forEach( ( name ) => {
|
2022-12-07 14:26:02 +00:00
|
|
|
storybookConfig.resolve.alias[ `@woocommerce/${ name }` ] =
|
|
|
|
path.resolve( __dirname, `../../packages/js/${ name }/src` );
|
2020-04-29 17:03:20 +00:00
|
|
|
} );
|
|
|
|
|
2021-06-02 03:54:00 +00:00
|
|
|
storybookConfig.resolve.alias[ '@woocommerce/settings' ] = path.resolve(
|
|
|
|
__dirname,
|
2022-01-07 05:05:22 +00:00
|
|
|
'./setting.mock.js'
|
2021-06-02 03:54:00 +00:00
|
|
|
);
|
|
|
|
|
2024-06-13 05:05:28 +00:00
|
|
|
storybookConfig.resolve.alias[ 'react/jsx-runtime' ] =
|
|
|
|
require.resolve( 'react/jsx-runtime' );
|
|
|
|
|
|
|
|
// We need to use react 18 for the storybook since some dependencies are not compatible with react 17
|
|
|
|
// Once we upgrade react to 18 in repo, we can remove this alias
|
|
|
|
storybookConfig.resolve.alias.react = require.resolve( 'react18' );
|
|
|
|
|
2020-05-19 13:16:19 +00:00
|
|
|
storybookConfig.resolve.modules = [
|
2022-04-27 21:54:54 +00:00
|
|
|
path.join( __dirname, '../../plugins/woocommerce-admin/client' ),
|
2023-12-19 16:09:30 +00:00
|
|
|
path.join( __dirname, '../../packages/js/product-editor/src' ),
|
2020-05-19 13:16:19 +00:00
|
|
|
'node_modules',
|
|
|
|
];
|
|
|
|
|
2020-02-24 02:25:26 +00:00
|
|
|
storybookConfig.plugins.push(
|
2021-06-02 03:54:00 +00:00
|
|
|
...wcAdminWebpackConfig.plugins,
|
2022-03-18 10:59:05 +00:00
|
|
|
new CopyWebpackPlugin( {
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.resolve( __dirname, 'wordpress/css' ),
|
|
|
|
to: 'wordpress/css/[name][ext]',
|
|
|
|
},
|
2022-05-30 07:20:08 +00:00
|
|
|
{
|
|
|
|
from: require.resolve(
|
|
|
|
'@wordpress/components/build-style/style.css'
|
|
|
|
),
|
|
|
|
to: 'wordpress/css/components.css',
|
|
|
|
},
|
2022-03-18 10:59:05 +00:00
|
|
|
{
|
|
|
|
from: path.resolve(
|
|
|
|
__dirname,
|
2022-04-27 21:54:54 +00:00
|
|
|
`../../packages/js/components/build-style/*.css`
|
2022-03-18 10:59:05 +00:00
|
|
|
),
|
|
|
|
to: `./component-css/[name][ext]`,
|
|
|
|
},
|
2023-08-22 09:58:33 +00:00
|
|
|
{
|
|
|
|
from: path.resolve(
|
|
|
|
__dirname,
|
|
|
|
`../../packages/js/onboarding/build-style/*.css`
|
|
|
|
),
|
|
|
|
to: `./onboarding-css/[name][ext]`,
|
|
|
|
},
|
2023-12-19 16:09:30 +00:00
|
|
|
{
|
|
|
|
from: path.resolve(
|
|
|
|
__dirname,
|
|
|
|
`../../packages/js/product-editor/build-style/*.css`
|
|
|
|
),
|
|
|
|
to: `./product-editor-css/[name][ext]`,
|
|
|
|
},
|
2022-03-18 10:59:05 +00:00
|
|
|
{
|
|
|
|
from: path.resolve(
|
|
|
|
__dirname,
|
2022-04-27 21:54:54 +00:00
|
|
|
`../../packages/js/experimental/build-style/*.css`
|
2022-03-18 10:59:05 +00:00
|
|
|
),
|
|
|
|
to: `./experimental-css/[name][ext]`,
|
|
|
|
},
|
2023-07-24 12:34:38 +00:00
|
|
|
{
|
|
|
|
from: path.resolve(
|
|
|
|
__dirname,
|
|
|
|
`../../plugins/woocommerce/assets/client/admin/app/*.css`
|
|
|
|
),
|
|
|
|
to: `./app-css/[name][ext]`,
|
|
|
|
},
|
2022-03-18 10:59:05 +00:00
|
|
|
],
|
|
|
|
} )
|
2020-02-24 02:25:26 +00:00
|
|
|
);
|
|
|
|
|
2022-06-08 09:16:31 +00:00
|
|
|
storybookConfig.resolve.fallback = {
|
|
|
|
...storybookConfig.resolve.fallback,
|
|
|
|
// Ignore fs to fix resolve 'fs' error for @automattic/calypso-config
|
|
|
|
fs: false,
|
|
|
|
};
|
|
|
|
|
2020-02-24 02:25:26 +00:00
|
|
|
return storybookConfig;
|
|
|
|
};
|