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

Parcel/Svelte: styles are duplicated #138

Closed
jsonkao opened this issue May 1, 2020 · 4 comments · Fixed by #148
Closed

Parcel/Svelte: styles are duplicated #138

jsonkao opened this issue May 1, 2020 · 4 comments · Fixed by #148

Comments

@jsonkao
Copy link

jsonkao commented May 1, 2020

🐛 Bug Report

Styles are being duplicated. In a Svelte component like…

<div></div>>

<style>
  div {
    background: red;
    width: 100px;
    height: 100px;
  }
</style>

…DevTools shows these styles:
image

Seems to be related to sveltejs/sapper#1127.

🎛 Configuration (.svelterc, package.json, cli command)

package.json:

{
  "scripts": {
    "start": "parcel index.html"
  },
  "devDependencies": {
    "parcel-bundler": "^1.12.4",
    "parcel-plugin-svelte": "^4.0.6",
    "svelte": "^3.21.0"
  }
}

No extra configuration in Svelte rendering.

💻 Code Sample

Example repo: @jsonkao/svelte-parcel-duplicate-styles

@jsonkao jsonkao changed the title Styles are duplicated Parcel/Svelte: styles are duplicated May 1, 2020
@rondonjon
Copy link

The duplication is not the only problem.

I have tried to use CSS background images in this Svelte/Parcel template and couldn't get them to work.

It seems that the image files are copied to the dist folder, but their paths are broken; surprisingly only in one of the style copies, and unfortunately in the copy that takes precedence.

styles

@antony
Copy link
Contributor

antony commented May 22, 2020

This happened in the official Sapper build for a while, and a really random library upgrade stopped it happening. Might be related.

Edit: Ah, looks like it was rollup 2 which solved it. Maybe a starting point...

@canadaduane
Copy link
Contributor

Possibly related? parcel-bundler/parcel#2592

@canadaduane
Copy link
Contributor

I think I have a solution for this in the Parcel2 transformer that may apply here also (see orlov-vo/parcel-transformer-svelte#8)

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 a pull request may close this issue.

4 participants