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' );
|
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 ) => {
|
|
|
|
storybookConfig.resolve.alias[
|
|
|
|
`@woocommerce/${ name }`
|
2022-04-27 21:54:54 +00:00
|
|
|
] = 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
|
|
|
);
|
|
|
|
|
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' ),
|
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]`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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]`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
} )
|
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;
|
|
|
|
};
|