embroider icon indicating copy to clipboard operation
embroider copied to clipboard

Did not emit the additional css entry point

Open nightire opened this issue 4 years ago • 4 comments

We have an outputPaths option in ember-cli-build.js:

outputPaths: {
  app: {
    css: {
      app: '/assets/bundle.css',
      other: '/assets/other.css',
    },
  },
},

switch to embroider (with default options) did not emit the /assets/other.css file, any suggestions?

nightire avatar Feb 20 '21 13:02 nightire

I'm seeing the same issue when trying to make my sass compiler addon work with embroider.

The build hook gets called only once, with the 'standard' css file, but not the additional

mfeckie avatar Mar 31 '21 10:03 mfeckie

After poking around a bit, I can see that the file does get built, but it looks like it doesn't get included in the index.html

This looks to be the place it's happening https://github.com//embroider-build/embroider/blob/2ac6e44630588ba8718d625f8cf9b77bc66931db/packages/core/src/app.ts#L430

mfeckie avatar Mar 31 '21 11:03 mfeckie

It looks like it intentionally ignores outputPaths for CSS, based off this comment.

Which is a bit odd, because that breaks expected behavior for from the Ember docs.

I'm hoping to find a way around it, because there are sometimes valid reasons to break up your final CSS bundle into multiple assets.

naiyt avatar Apr 08 '21 17:04 naiyt

We could probably make this work as part of @embroider/compat. But this whole area of CSS handling is essentially a legacy behavior.

Under embroider, you can declare exactly which parts of your app need which CSS files via imports, and then load it all lazily on demand via either await import() or Embroider's splitAtRoutes.

The rule is, if you say import "./some.css" with an explicit .css extension, embroider guarantees that that css file will be loaded into the DOM before the importing javascript module evaluates.

ef4 avatar Apr 09 '21 14:04 ef4