-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Schematic fixes #10388
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
Schematic fixes #10388
Changes from 4 commits
6902ba2
024c88a
ca67c2d
76f0947
bc45968
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,23 @@ export function getIndexHtmlPath(host: Tree) { | |
const app = getAppFromConfig(config, '0'); | ||
return normalize(`/${app.root}/${app.index}`); | ||
} | ||
|
||
/** | ||
* Get the root stylesheet file. | ||
*/ | ||
export function getStylesPath(host: Tree) { | ||
const config = getConfig(host); | ||
const app = getAppFromConfig(config, '0'); | ||
const styles = app.styles.find(style => { | ||
const str = style.toString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const styles = app.styles.find(s => /styles\.(c|le|sc)ss/.test(s)); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fancy ;P |
||
return str === 'styles.css' || | ||
str === 'styles.less' || | ||
str === 'styles.scss'; | ||
}); | ||
|
||
if (!styles) { | ||
throw new SchematicsException(`Could not find global styles.ext file.`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it valid to call your root style file something else entirely? Can we read the first stylesheet from the config? Would it be better to just no-op if we can't find it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well there is just a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I know if I was making a large app, I wouldn't want to have a file called |
||
} | ||
|
||
return normalize(`/${app.root}/${styles}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally prefer to not rely on newlines in template strings since it's not immediately obvious that they're intentional and someone might remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I agree. Got a better alternative? Just
/n
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, just
\n
is obvious that it's intentional