mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-28 00:17:12 +01:00
chore: support css modules in storybook
This commit is contained in:
parent
4a795966d1
commit
790bd4da0f
@ -1,5 +1,3 @@
|
|||||||
const path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
stories: [
|
stories: [
|
||||||
'../src/**/*.stories.mdx',
|
'../src/**/*.stories.mdx',
|
||||||
@ -19,7 +17,48 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
webpackFinal: async (config) => {
|
webpackFinal: async (config) => {
|
||||||
config.resolve.alias['@site'] = path.resolve(__dirname, '../');
|
const path = require('path');
|
||||||
return config;
|
|
||||||
|
config.resolve.alias = {
|
||||||
|
...config.resolve.alias,
|
||||||
|
'@site': path.resolve(__dirname, '../'),
|
||||||
|
};
|
||||||
|
|
||||||
|
const rules = config.module.rules.map((rule) => {
|
||||||
|
if (rule.test.toString() !== '/\\.css$/') {
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
const use = rule.use.map((u) => {
|
||||||
|
const { loader } = u;
|
||||||
|
|
||||||
|
if (!loader || !loader.includes('/css-loader/')) {
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
...u.options,
|
||||||
|
modules: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...u,
|
||||||
|
options,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...rule,
|
||||||
|
use,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
module: {
|
||||||
|
...config.module,
|
||||||
|
rules,
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user