mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
7374f380bd
* chore(grafanaui): bump storybook to 6.2, remove nohoist babel conflict hack * chore(grafanaui): update storybook react doc gen defaults * feat(grafanaui): map public/img as storybook static path for images/icons * refactor(grafanaui): remove storybook noopControl in favour of parameters.controls.exclude * feat(grafanaui): add component for storybook docs theming * chore(grafanaui): silence button docs react warnings * chore(grafanaui): bump storybook to v6.2.3 * revert(grafanaui): remove test description param from legacy switch story
143 lines
3.7 KiB
TypeScript
143 lines
3.7 KiB
TypeScript
const path = require('path');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
|
|
|
|
const stories = ['../src/**/*.story.{js,jsx,ts,tsx,mdx}'];
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
stories.push('../src/**/*.story.internal.{js,jsx,ts,tsx,mdx}');
|
|
}
|
|
|
|
module.exports = {
|
|
stories: stories,
|
|
addons: [
|
|
{
|
|
name: '@storybook/addon-essentials',
|
|
options: {
|
|
backgrounds: false,
|
|
},
|
|
},
|
|
'@storybook/addon-knobs',
|
|
'@storybook/addon-storysource',
|
|
'storybook-dark-mode',
|
|
],
|
|
reactOptions: {
|
|
fastRefresh: true,
|
|
},
|
|
typescript: {
|
|
check: true,
|
|
reactDocgen: 'react-docgen-typescript',
|
|
reactDocgenTypescriptOptions: {
|
|
tsconfigPath: path.resolve(__dirname, 'tsconfig.json'),
|
|
shouldExtractLiteralValuesFromEnum: true,
|
|
shouldRemoveUndefinedFromOptional: true,
|
|
propFilter: (prop: any) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
|
|
savePropValueAsString: true,
|
|
},
|
|
},
|
|
webpackFinal: async (config: any, { configType }: any) => {
|
|
const isProductionBuild = configType === 'PRODUCTION';
|
|
config.module.rules = [
|
|
...(config.module.rules || []),
|
|
{
|
|
test: /\.tsx?$/,
|
|
use: [
|
|
{
|
|
loader: require.resolve('ts-loader'),
|
|
options: {
|
|
transpileOnly: true,
|
|
configFile: path.resolve(__dirname, 'tsconfig.json'),
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: /\.scss$/,
|
|
use: [
|
|
{
|
|
loader: 'style-loader',
|
|
options: { injectType: 'lazyStyleTag' },
|
|
},
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 2,
|
|
},
|
|
},
|
|
{
|
|
loader: 'postcss-loader',
|
|
options: {
|
|
sourceMap: false,
|
|
config: { path: __dirname + '../../../../scripts/webpack/postcss.config.js' },
|
|
},
|
|
},
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
sourceMap: false,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
{
|
|
test: require.resolve('jquery'),
|
|
use: [
|
|
{
|
|
loader: 'expose-loader',
|
|
query: 'jQuery',
|
|
},
|
|
{
|
|
loader: 'expose-loader',
|
|
query: '$',
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
config.optimization = {
|
|
nodeEnv: 'production',
|
|
moduleIds: 'hashed',
|
|
runtimeChunk: 'single',
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
minChunks: 1,
|
|
cacheGroups: {
|
|
vendors: {
|
|
test: /[\\/]node_modules[\\/].*[jt]sx?$/,
|
|
chunks: 'initial',
|
|
priority: -10,
|
|
reuseExistingChunk: true,
|
|
enforce: true,
|
|
},
|
|
default: {
|
|
priority: -20,
|
|
chunks: 'all',
|
|
test: /.*[jt]sx?$/,
|
|
reuseExistingChunk: true,
|
|
},
|
|
},
|
|
},
|
|
minimize: isProductionBuild,
|
|
minimizer: isProductionBuild
|
|
? [
|
|
new TerserPlugin({ cache: false, parallel: false, sourceMap: false, exclude: /monaco/ }),
|
|
new OptimizeCSSAssetsPlugin({}),
|
|
]
|
|
: [],
|
|
};
|
|
|
|
config.resolve.alias['@grafana/ui'] = path.resolve(__dirname, '..');
|
|
|
|
// Silence "export not found" webpack warnings with transpileOnly
|
|
// https://github.com/TypeStrong/ts-loader#transpileonly
|
|
config.plugins.push(
|
|
new FilterWarningsPlugin({
|
|
exclude: /export .* was not found in/,
|
|
})
|
|
);
|
|
|
|
return config;
|
|
},
|
|
};
|