-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: PostCSS config #2455
Comments
You can override the configuration with the full control mode: https://storybook.js.org/configurations/custom-webpack-config/#full-control-mode |
@igor-dv I know but I think it is simpler to move the postcss configs into it's own file. |
I think that most people are happy with the default settings. The extend and full control modes are for people like you who want to add or customize different webpack plugins. There are many more people who require custom babel configs than postcss configs. We try to keep the code and setup complexity to a minimum. If there is demand for this feature, we'd be happy to add it. |
I encountered the same issue, and I executed the following to use global const path = require('path');
module.exports = (baseConfig, env, defaultConfig) => {
defaultConfig.entry.styles = path.resolve(__dirname, '../src/styles/style.css');
const cssRule = defaultConfig.module.rules.find(r => r.test.toString() === /\.css$/.toString());
const postCssUse = cssRule.use.find(u => u.loader && u.loader.indexOf('postcss-loader') > -1);
delete postCssUse.options;
return defaultConfig;
}; I propose to check if we got a |
@jpetitcolas Sounds good. We could also support it in storybook config directory |
Hi @jpetitcolas, do you still think you might make a PR? I think it would be really helpful for storybook to detect/use a postcss config file. |
@jpetitcolas Thanks a lot! Good solution. Still works, should really be config for storybook :) |
So currently we still have this in our {
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
postcss: {},
plugins: () => [
require('postcss-flexbugs-fixes'), // eslint-disable-line
autoprefixer({
flexbox: 'no-2009',
}),
],
},
}, Does anyone want to open a PR fixing this issue? Essentially we should check for the existence of the postcss.config.js file and if present, not set options, Right? |
@ndelangen Im gonna get this. Was thinking of copying this approach: https://github.com/zeit/next-plugins/blob/master/packages/next-css/css-loader-config.js Are you okay with adding |
Yeah go for it 👍 |
Cool. So, I got I'd like to discuss more with whoever has been working on presets and webpack configuration as I see a few problems... The main issue is that postcss-loader exists as the first of many possible other loaders related to style loading, but never by itself. So, while the initial issue reads as: "Do this like you did with custom babel config" it feels as though it's not the same paradigm. Example would be postcss-loader to sass-loader to css-loader to style-loader (from bottom to top in an array of loaders within module.rules) Another issue would be that the default storybook config (as for as PostCSS config is concerned) is clearly conducive to React, but not vue-loader although it seems like @pksunkara is resolving that issue in a different manner. The specific example of React vs. Vue isn't the issue though, it's that I'm not aware of whether or not this default webpack config's style-loading rules even get utilized in some frameworks/examples (for example, in the Marko or Angular one). If the default webpack config is not gonna be leveraged - and custom PostCSS rule loading will only be an aspect of React's preset - maybe we make this change there. If you'd like your |
I believe that this issue can be closed now that |
Yup, closing this based on #13669 |
Instead of hardcoding the postcss options into the default webpack config, I suggest moving this to a
postcss.config.js
file.https://github.com/storybooks/storybook/blob/master/app/react/src/server/config/defaults/webpack.config.js#L21
This way it can be overwritten in your own project, similar to the
babel.js
config.https://github.com/storybooks/storybook/blob/master/app/react/src/server/config/babel.js
https://github.com/storybooks/storybook/blob/585beccafdc4ea320d262b8d4db4b35b959007ef/app/react/src/server/babel_config.js
The text was updated successfully, but these errors were encountered: