@storybook/angular does not autoprefix as angular-cli
See original GitHub issueDescribe the bug @storybook/angular does not respect .browserlist or any other way described in angualr story autoprexier
To Reproduce
- generate angular projekt: https://storybook.js.org/basics/guide-angular/
- add .browserslistrc to root (see code snippet for example)
- create component + story with css property that should be autoprefixed (e.g. apperance: none, display: flex, )
- start storybook
Expected behavior the generated css with storybook should contain prefixed css properties
Screenshots
If applicable, add screenshots to help explain your problem.
with work around:
Code snippets story
import { moduleMetadata, storiesOf } from '@storybook/angular';
import { CheckboxComponent } from './checkbox.component';
const stories = storiesOf('Input/Checkbox', module)
.addDecorator(
moduleMetadata({
entryComponents: [CheckboxComponent],
declarations: [CheckboxComponent],
})
);
stories.add('unchecked', () => ({
template: `<input prefix-checkbox type="checkbox">`
}));
component:
@Component({
selector: 'input[prefix-checkbox]',
templat: '<ng-content></ng-content>,
styleUrls: ['./checkbox.component.scss']
})
export class CheckboxComponent {
}
style:
:host {
appearance: none;
}
.browserslistrc
### Supported Browsers
last 2 version
IE >= 10
generated css should be:
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
System:
- Framework: [e.g. react, vue, angular]
- Addons: [@storybook/angular]
- Version: [4.1.11]
Additional context at the moment I am useing a project webpack config to work around this problem:
module.exports = baseConfig => {
let cssRule = baseConfig.module.rules.find(
rule => rule.test.toString() === /\.s(c|a)ss$/.toString()
);
if (!cssRule) {
throw new Error('css rule for modification not found');
}
cssRule.use = [
{ loader: require.resolve('raw-loader') },
{ loader: require.resolve('postcss-loader'),
options: {
plugins: [
require('autoprefixer')
]
}
},
{ loader: require.resolve('sass-loader') },
];
return baseConfig;
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Storybook for Angular fails with default/initial library config ...
Storybook for Angular fails to build with default (initial) library configuration. It'll complain about a missing tsConfig setting. But the ...
Read more >Build a simple component in isolation - Storybook Tutorials
We'll build our UI following a Component-Driven Development (CDD) methodology. It's a process that builds UIs from the “bottom-up”, starting with components ...
Read more >NX Storybook - Angular UI Library no automatic recompile ...
Running storybook outside nx or angular 12 is watching for code changes and rebuilds everything once the code has changed. Inside NX context...
Read more >Manipulate Angular components with content projection in ...
npx @angular/cli@13.3.0 new ng-content-storybook --style=scss --prefix=evil-corp --strict=true --routing=true. Then we can add the Storybook ...
Read more >Angular & Storybook. Building & Documenting UI Components
Adding Storybook to an Angular project is pretty straight-forward. First, we run the command below to install Storybook in our project, already ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I will create a merge request modifying https://github.com/storybooks/storybook/blob/4da246bbe9413510b48d1ab8b9faf4fae4656d92/app/angular/src/server/framework-preset-angular.js to add this behavior to @storybook/angular.
I have two questions:
will throw
but using require.resolve in postcss plugin will not work and throw when used in project
Yowza!! I just released https://github.com/storybooks/storybook/releases/tag/v5.1.0-alpha.6 containing PR #5612 that references this issue. Upgrade today to try it out!
Because it’s a pre-release you can find it on the
@next
NPM tag.Closing this issue. Please re-open if you think there’s still more to do.