Correct storybook's css and font loading

This commit is contained in:
Eric 2020-07-15 12:50:14 -05:00 committed by Eric Schultz
parent 6ca0d1b9b6
commit 5609d26921

View file

@ -4,9 +4,10 @@ process.env.NODE_ENV = "development";
const railsWebpackEnv = require("../config/webpack/environment"); const railsWebpackEnv = require("../config/webpack/environment");
module.exports = { module.exports = {
stories: ["../app/javascript/stories/*.[tj]s?(x)"], stories: ["../app/javascript/**/*.stories.[tj]s?(x)"],
addons: ['@storybook/addon-actions', '@storybook/addon-links', 'storybook-addon-intl'], addons: ['@storybook/addon-actions', '@storybook/addon-links', 'storybook-addon-intl'],
webpackFinal: (config) => ({ webpackFinal: (config) => {
const result = {
// do mutation to the config // do mutation to the config
...config, ...config,
resolve: { resolve: {
@ -17,12 +18,23 @@ module.exports = {
module: { module: {
...config.module, ...config.module,
rules: railsWebpackEnv.loaders rules: railsWebpackEnv.loaders
.filter((i) => i.key !== "nodeModules") .filter((i) => !["nodeModules", //not sure why this is here
"moduleCss" // this addresses issues with our webpack config for css not matching what storybook wants
].includes(i.key) )
.map((i) => i.value), .map((i) => i.value),
}, },
plugins: [ plugins: [
...config.plugins, ...config.plugins,
...railsWebpackEnv.plugins.map((i) => i.value), ...railsWebpackEnv.plugins.map((i) => i.value),
], ],
}),
};
result.module.rules.filter((i) => i.test.test('.ttf')).forEach((i) => {
i.use=['url-loader']
})
return result;
},
}; };