make storybook working for airwatch
This commit is contained in:
parent
fd12bbb259
commit
f82c393394
2 changed files with 64 additions and 41 deletions
|
@ -1,59 +1,86 @@
|
||||||
import type { StorybookConfig } from '@storybook/angular';
|
import {StorybookConfig} from '@storybook/angular';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
const config: StorybookConfig = {
|
const config: StorybookConfig = {
|
||||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
||||||
addons: [
|
addons: [
|
||||||
'@storybook/addon-links',
|
'@storybook/addon-links',
|
||||||
// '@storybook/addon-essentials', // Commented out due to compatibility issues with Storybook v9
|
'@storybook/addon-docs',
|
||||||
// '@storybook/addon-interactions', // Commented out due to compatibility issues with Storybook v9
|
// ... autres addons
|
||||||
],
|
],
|
||||||
framework: {
|
framework: {
|
||||||
name: '@storybook/angular',
|
name: '@storybook/angular',
|
||||||
options: {},
|
options: {}
|
||||||
},
|
},
|
||||||
// docs: {
|
|
||||||
// autodocs: 'tag',
|
|
||||||
// },
|
|
||||||
staticDirs: ['../src/stories/assets', '../src/app/styles/typo'], // Pour les assets statiques et les polices
|
|
||||||
webpackFinal: async (config) => {
|
webpackFinal: async (config) => {
|
||||||
// Add support for MDX files
|
|
||||||
if (config.module?.rules) {
|
if (config.module?.rules) {
|
||||||
|
// Support MDX
|
||||||
config.module.rules.push({
|
config.module.rules.push({
|
||||||
test: /\.mdx?$/,
|
test: /\.mdx?$/,
|
||||||
use: [
|
use: [{loader: require.resolve('@mdx-js/loader')}],
|
||||||
{
|
|
||||||
loader: require.resolve('@mdx-js/loader'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add support for font files
|
// Support fonts amélioré
|
||||||
config.module.rules.push({
|
config.module.rules.push({
|
||||||
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
||||||
use: [
|
type: 'asset/resource',
|
||||||
{
|
generator: {filename: 'fonts/[name].[contenthash][ext]'},
|
||||||
loader: 'file-loader',
|
});
|
||||||
options: {
|
|
||||||
name: '[name].[ext]',
|
// NOUVELLE SOLUTION : Configurer css-loader pour gérer les URLs
|
||||||
outputPath: 'fonts/',
|
const scssRules = config.module.rules.filter(rule => {
|
||||||
},
|
if (rule && typeof rule === 'object' && 'test' in rule && rule.test) {
|
||||||
},
|
const testString = rule.test.toString();
|
||||||
],
|
return testString.includes('scss') || testString.includes('sass');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
scssRules.forEach(rule => {
|
||||||
|
if (rule && typeof rule === 'object' && 'use' in rule && Array.isArray(rule.use)) {
|
||||||
|
const cssLoaderIndex = rule.use.findIndex((loader: any) => {
|
||||||
|
if (typeof loader === 'string') {
|
||||||
|
return loader.includes('css-loader');
|
||||||
|
}
|
||||||
|
return loader && loader.loader && loader.loader.includes('css-loader');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (cssLoaderIndex !== -1) {
|
||||||
|
const cssLoader = rule.use[cssLoaderIndex] as any;
|
||||||
|
if (typeof cssLoader === 'object' && cssLoader.options) {
|
||||||
|
cssLoader.options.url = {
|
||||||
|
filter: (url: string) => {
|
||||||
|
// Skip problematic URLs with complex relative paths
|
||||||
|
if (url.includes('../../../../my-workspace/')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add alias for tilde (~) notation to resolve to the project root
|
// Alias
|
||||||
if (!config.resolve) {
|
if (!config.resolve) config.resolve = {};
|
||||||
config.resolve = {};
|
if (!config.resolve.alias) config.resolve.alias = {};
|
||||||
}
|
|
||||||
if (!config.resolve.alias) {
|
config.resolve.alias['~src'] = path.resolve(__dirname, '../src');
|
||||||
config.resolve.alias = {};
|
config.resolve.alias['sae-lib'] = path.resolve(__dirname, '../node_modules/sae-lib');
|
||||||
}
|
|
||||||
config.resolve.alias['~src'] = require('path').resolve(__dirname, '../src');
|
// Ajouter un alias pour remixicon
|
||||||
|
config.resolve.alias['remixicon'] = path.resolve(__dirname, '../node_modules/remixicon');
|
||||||
|
|
||||||
|
// Modules resolution
|
||||||
|
if (!config.resolve.modules) config.resolve.modules = [];
|
||||||
|
config.resolve.modules.push(path.resolve(__dirname, '../node_modules'));
|
||||||
|
|
||||||
|
config.resolve.symlinks = true;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
|
import type {Preview} from '@storybook/angular';
|
||||||
import type { Preview } from '@storybook/angular';
|
|
||||||
|
|
||||||
// Import des styles globaux
|
|
||||||
import '../src/app/styles/styles.scss';
|
|
||||||
|
|
||||||
const preview: Preview = {
|
const preview: Preview = {
|
||||||
parameters: {
|
parameters: {
|
||||||
actions: { argTypesRegex: '^on[A-Z].*' },
|
actions: {argTypesRegex: '^on[A-Z].*'},
|
||||||
controls: {
|
controls: {
|
||||||
matchers: {
|
matchers: {
|
||||||
color: /(background|color)$/i,
|
color: /(background|color)$/i,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue