-
-
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
Angular 6 Expected 'styles' to be an array of strings. #3593
Comments
This is an update for this issue. In alpha.6, the aforementioned issues can be resolved by extending the webpack.config.json in .storybook directory:
After getting this config file, the error becomes to |
It fixes "Expected 'styles' to be an array of strings." error, but works not correct. |
@nglazov I suppose that will be taken care of by the dev teams. :) Really hope it to work soon. |
Does interface NgStory correct? How about // app/angular/src/client/preview/angular/types.ts
export interface NgStory {
component?: any;
props: ICollection;
propsMeta?: ICollection;
moduleMetadata?: NgModuleMetadata;
template?: string;
styles?: string[];
} Should we update initModule too? It doesn't seem to handle components which use // app/angular/src/client/preview/angular/helpers.ts
const initModule = (currentStory: IGetStory): Function => {
const storyObj = currentStory();
const { component, template, props, styles, moduleMetadata = {} } = storyObj;
let AnnotatedComponent;
if (template) {
AnnotatedComponent = createComponentFromTemplate(template, styles);
} else {
AnnotatedComponent = component;
}
const story = {
component: AnnotatedComponent,
props,
};
return getModule(
[AppComponent, AnnotatedComponent],
[AnnotatedComponent],
[AppComponent],
story,
moduleMetadata
);
}; |
@wuyuanyi135 your workaround seems to work that's the way it should be shipped (In my case I didn't need the id part but your webpack config is a must) |
@agalazis True. I believe it was after alpha 7 where the |
Has anyone tried the latest alpha? it supports Angular 6. |
I'm still struggling to make it work. A part of the issue might be the fact that I'm using
|
If you are using scss and angular-cli, storybook should work without configuring anything. |
I fixed this issue by using |
I assume we are ok here, right? |
I'm using alpha.14 and experiencing the same issue, but with Weback config: const path = require('path');
module.exports = {
module: {
rules: [
{
test: /\.less$/,
loaders: ['style-loader', 'css-loader', 'less-loader'],
include: path.resolve(__dirname, '../'),
},
{
test: /\.(jpe?g|png|gif)$/,
use: 'file-loader?name=img/[name]-[hash].[ext]'
},
{
test: /\.(eot|woff2?|svg|ttf)([\?]?.*)$/,
use: 'file-loader',
},
],
},
}; |
AFAIR, |
Sadly, removing the
By the looks of it, |
Could you please give me a URL to the example commit? I'm trying to reproduce it locally, but failing. |
I fixed the issue by changing the LESS loader to this:
Honestly - no idea why it works now. |
I didn't commit this specific example. since there was nothing special. The official example app is here , though, you need to bootstrap the whole monorepo to be able to run it. Anyway, to understand what is wrong in your setup we need a reproduction 🤷♂️ |
Yeah, that's completely understandable. Since I somehow managed to solve the issue on my project, I'll get out of your hair. Thanks for the patience! :) |
FYI, this issue will arise if you misspell any part of the file name as well. Like, leaving off the .scss extension. |
I followed @wuyuanyi135 solution.
Here's my webpack code (same as @wuyuanyi135):
Adding |
i have fixed this issue with changing just lower case styles extensions |
@DmitryEfimenko Hi Dmitry! How did you solve your issue with |
This error could be caused by a improper (ie too new) version of See TheLarkInn/angular2-template-loader#86 Setting it to |
Thanx man! You saved my day
|
To fix the The debug flag Using the angular-cli setup was not an option for us as we run a custom webpack build. The final version of the customization looks as follow.
|
Instead of ‘style-loader’, ‘css-loader’, ‘sass-loader’ |
If you are reporting a bug or requesting support, start here:
Bug or support request summary
I want to use storybook with Angular 6. It turns out I have to use the 4.0.0 alpha branch to make it through (#3044 ). After I managed to make the story server run, I got another error
Expected 'styles' to be an array of strings.
, which I have no idea how to get around.Steps to reproduce
I followed the instructions in https://storybook.js.org/basics/guide-angular/#docs-content but at the beginning the compilation failed:
Then I installed @storybook/[email protected]. I managed to run the server, but when I load my component, it shows
Please specify which version of Storybook and optionally any affected addons that you're running
The text was updated successfully, but these errors were encountered: