-
Notifications
You must be signed in to change notification settings - Fork 109
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
Bundle CSS files #205
Bundle CSS files #205
Conversation
If the webpack config causes css files to be included in the output, they will be appended to vendor.css/test-support.css.
Thanks, this looks nice. I'm fine with building in CSS bundling, as long as we codify what semantics we're supporting (rather than locking into "whatever mini-css-extract-plugin does". I was already planning to go this same direction with embroider, and ember-auto-import is (in one sense) a polyfill for embroider. The embroider addon spec has this section on CSS. Could you add the appropriate webpack config to this PR, so it works out-of-the-box? |
(The webpack config gets generated here, and if you're adding a plugin we should be sure to |
@ef4 as a disclaimer, I'm kind of a webpack n00b -- I've barely used it outside the purview of I also had some vague notions about maybe in the future providing a config to Anyway, if somebody more experienced with webpack than I am says that tightly coupling So please let me know how you'd like to proceed here -- I'm game for anything, I just want to be clear that I have not nearly enough webpack domain knowledge here to make the call myself. |
Hey @ef4 any more thoughts here? I'm getting to the point in my project that I'm going to have to run off a local tarball of |
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.
Ok, I now I understand better what you're trying to achieve here. We're really just making it so that if somebody configures webpack to emit CSS, we will grab it and include it into the ember app. I'm fine with that as a lower-level feature for the present.
I noticed one small type issue, if you can fix that up we can merge this.
Thanks for all this effort.
@@ -200,7 +209,7 @@ interface PassthroughEntry extends WalkSyncEntry { | |||
|
|||
type AugmentedWalkSyncEntry = WalkSyncEntry | PassthroughEntry; | |||
|
|||
function findByPrefix(path: string, map: Map<string, string>) { | |||
function findByPrefix(path: string, map: Map<string, any>) { |
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 think we can replace any
here with Map<string, string>
?
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.
It can't just be Map<string, string>
because we call it with both this.passthrough
and this.mappings
, and this PR changes this.mappings
to Map<string, Map<string, string>>
(but leaves this.passthrough
as Map<string, string>
). So maybe we could do Map<string, string | Map<string, string>>
but I thought since the function itself is agnostic as to what the values of the map are, it made sense to leave it as any
. But I'm happy to change it to an |
if you prefer.
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.
Ah, in that case it should be:
function findByPrefix<T>(path: string, map: Map<string, T>) {
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.
Ah, TIL! I'm still kinda new to typescript also. I just pushed a commit (didn't squash/rebase or anything -- figured you could just do that when merging).
Released in 1.3.0. |
🎉 thank you! |
I took a stab at the most basic level of support for CSS. These changes make
ember-auto-import
bundle any CSS found in the webpack output, so by specifying a webpack config that collects CSS, e.g. mini-css-extract-plugin, we can include CSS in Ember's vendor.css.My personal use case is integrating CKEditor5 into my build. Rather than using one of their pre-built packages, I want to build/customize my own, and consume their source packages using
ember-auto-import
to mimic the webpack build they use to generate the pre-built packages. It appears to work seamlessly for the Javascript, but I need to do something like this to get the CSS, which motivated this PR.A few notes about this PR:
ember-auto-import
's code, so please let me know if this isn't the right approach.ember-auto-import
's tree is by customizing the webpack config to do so, so maybe that's opt-in enough?