Last active
September 7, 2021 12:11
-
-
Save ademilter/5f56fe9e56c5eb8725292274c68001c5 to your computer and use it in GitHub Desktop.
postcss config for storybook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- webpack.config.js | |
- postcss.config.js | |
- config.js | |
- addons.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { configure } from '@storybook/react' | |
import '../src/styles/main.css' | |
const req = require.context('../stories', true, /.stories.js$/) | |
function loadStories() { | |
req.keys().forEach(filename => req(filename)) | |
} | |
configure(loadStories, module) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
plugins: { | |
// PostCSS Preset Env includes autoprefixer and browsers option will be passed to it automatically. | |
'postcss-preset-env': { | |
stage: 0, | |
browsers: 'last 2 versions' | |
// importFrom: 'path/to/file.css' | |
}, | |
'postcss-import': {}, | |
'postcss-nested': {} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
module: { | |
rules: [ | |
{ | |
test: /\.css$/, | |
use: [ | |
{ | |
loader: 'style-loader', | |
options: { sourceMap: true } | |
}, | |
{ | |
loader: 'css-loader', | |
options: { sourceMap: true } | |
}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
sourceMap: true, | |
config: { | |
path: './.storybook/' | |
} | |
} | |
} | |
] | |
} | |
] | |
} | |
} |
Has anyone tried configuring postcss with scss files?
Anyone has configuration postcss for Angular?
@Abramovick you saved my life 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @Abramovick!
This was the only working postcss example for storybook5.