Skip to content
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

Fix assets referenced in CSS not copied in prod builds #570

Merged
merged 1 commit into from
May 2, 2021

Conversation

marvinhagemeister
Copy link
Member

@marvinhagemeister marvinhagemeister commented May 1, 2021

When an asset is referenced in a CSS file we didn't copy the files over to our output directory.

@import "foo.css"; /* <- wasn't copied */

body {
  background: url('foo.jpg'); /* <- wasn't copied either */
}

@changeset-bot
Copy link

changeset-bot bot commented May 1, 2021

🦋 Changeset detected

Latest commit: 18b8f00

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wmr Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@marvinhagemeister marvinhagemeister force-pushed the css-assets branch 2 times, most recently from 8fcbe3a to 39faab6 Compare May 1, 2021 19:08
@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2021

Size Change: +325 B (0%)

Total Size: 736 kB

Filename Size Change
packages/wmr/wmr.cjs 702 kB +325 B (0%)
ℹ️ View Unchanged
Filename Size Change
examples/demo/dist/about/index.html 672 B 0 B
examples/demo/dist/assets/Calendar.********.css 702 B 0 B
examples/demo/dist/assets/style.********.css 624 B 0 B
examples/demo/dist/chunks/class-fields.********.js 208 B 0 B
examples/demo/dist/chunks/compat.********.js 15.3 kB 0 B
examples/demo/dist/chunks/index.********.js 261 B 0 B
examples/demo/dist/chunks/json.********.js 235 B 0 B
examples/demo/dist/chunks/prerender.********.js 2.46 kB 0 B
examples/demo/dist/class-fields/index.html 656 B 0 B
examples/demo/dist/compat/index.html 1.56 kB 0 B
examples/demo/dist/env/index.html 728 B 0 B
examples/demo/dist/error/index.html 661 B 0 B
examples/demo/dist/files/index.html 691 B 0 B
examples/demo/dist/index.********.js 7.45 kB 0 B
examples/demo/dist/index.html 720 B 0 B
examples/demo/dist/json/index.html 670 B 0 B
examples/demo/dist/lazy-and-late/index.html 674 B 0 B

compressed-size-action

Comment on lines 135 to +141
source = transformCss(source);
}

// Note: `plugin.generateBundle` is only called during prod builds for
// CSS files. So we need to guard the url replacement code.
if (production) {
source = await transformCssImports(source, idRelative, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder for myself: would be cool to implement transformCssImports within the transformCss pass so that it can use the Stylis AST.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@developit the middlewares in stylis are expected to be synchronous, but our resolution mechanism is async. I'm not sure how we could avoid parsing the CSS twice with that restriction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point. It would have to be two-pass, which would be less than ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants