mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 01:44:03 +03:00
bd5c0c1f20
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5680 GitOrigin-RevId: e0cc1686ce489142097ba1efdcb6f2ca8c65a093
114 lines
3.2 KiB
JavaScript
114 lines
3.2 KiB
JavaScript
const util = require('util');
|
|
const webpack = require('webpack');
|
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
const path = require('path');
|
|
const remarkSlug = require('remark-slug');
|
|
const remarkExternalLinks = require('remark-external-links');
|
|
|
|
const isConfigDebugMode = process.env.STORYBOOK_CONFIG_LOG === 'debug';
|
|
|
|
module.exports = {
|
|
stories: ['../src/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
babel: async options => {
|
|
if (isConfigDebugMode) {
|
|
console.log('------BABEL--------');
|
|
console.log(util.inspect(options, { showHidden: false, depth: null }));
|
|
}
|
|
return options;
|
|
},
|
|
webpackFinal: async config => {
|
|
config.module.rules.push(
|
|
{
|
|
test: /\.scss$/,
|
|
use: [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 2,
|
|
modules: {
|
|
localIdentName: '[local]___[hash:base64:5]',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
// Prefer `dart-sass`
|
|
implementation: require('sass'),
|
|
sassOptions: {
|
|
outputStyle: 'expanded',
|
|
},
|
|
sourceMap: true,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.mjs$/,
|
|
include: /node_modules/,
|
|
type: 'javascript/auto',
|
|
}
|
|
);
|
|
config.plugins.push(
|
|
new webpack.DefinePlugin({
|
|
CONSOLE_ASSET_VERSION: Date.now().toString(),
|
|
'process.hrtime': () => null,
|
|
__CLIENT__: true,
|
|
__SERVER__: false,
|
|
__DEVELOPMENT__: true,
|
|
__DEVTOOLS__: true, // <-------- DISABLE redux-devtools HERE
|
|
})
|
|
);
|
|
config.resolve.plugins.push(
|
|
new TsconfigPathsPlugin({
|
|
configFile: path.resolve(__dirname, '../tsconfig.json'),
|
|
})
|
|
);
|
|
// Fix storybook bug preventing ids to be added to MDX items https://github.com/storybookjs/storybook/issues/18395
|
|
config.module.rules.map(rule => {
|
|
const useWithMdxCsfLoader = rule?.use?.find(use =>
|
|
use?.loader?.includes('@storybook/mdx1-csf')
|
|
);
|
|
if (useWithMdxCsfLoader) {
|
|
useWithMdxCsfLoader.options = {
|
|
skipCsf: false,
|
|
remarkPlugins: [remarkSlug, remarkExternalLinks],
|
|
};
|
|
}
|
|
return rule;
|
|
});
|
|
config.resolve.alias['@'] = path.resolve(__dirname, '../src');
|
|
|
|
if (isConfigDebugMode) {
|
|
console.log('------WEBPACK--------');
|
|
console.log(util.inspect(newConfig, { showHidden: false, depth: null }));
|
|
}
|
|
|
|
// Return the altered config
|
|
return config;
|
|
},
|
|
addons: [
|
|
{
|
|
name: '@storybook/addon-postcss',
|
|
options: {
|
|
postcssLoaderOptions: {
|
|
implementation: require('postcss'),
|
|
postcssOptions: {
|
|
config: path.resolve(__dirname, '../postcss-storybook.config.js'),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'@storybook/addon-docs',
|
|
'@storybook/addon-links',
|
|
'@storybook/addon-essentials',
|
|
'@storybook/addon-interactions',
|
|
'storybook-dark-mode/register',
|
|
],
|
|
features: {
|
|
interactionsDebugger: true,
|
|
babelModeV7: true,
|
|
},
|
|
};
|