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

"Shorter CSS naming algorithm" update causes breaking changes in projects that do not use output hashes #5134

Closed
1 task
Enteleform opened this issue Oct 20, 2022 · 8 comments · Fixed by #5353
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@Enteleform
Copy link
Contributor

Enteleform commented Oct 20, 2022

What version of astro are you using?

1.5.2

Are you using an SSR adapter? If so, which one?

no

What package manager are you using?

yarn

What operating system are you using?

Windows

Describe the Bug

After upgrading from 1.3.0 to 1.5.2, I noticed that an issue with missing CSS was introduced in astro build.

It seems to be a result of #5036


When using this configuration:

vite: {
  build: {
    rollupOptions: {
      output: {
        assetFileNames: "assets/[name][extname]",
        entryFileNames: "[name].js",
      }
    }
  }
}

the build output with 1.3.0 was:

/dist/
  /assets/
    Page_A.css
    Page_A-Page_B.css
    Page_B.css

The current build output with 1.5.2 is:

/dist/
  /assets/
    Page_A.css
    Page_B.css

and the following warning is displayed:

12:27:06 PM [build] Building static entrypoints...
The emitted file "assets/Page_A.css" overwrites a previously emitted file of the same name.

Participation

  • I am willing to submit a pull request for this issue.
@peterpeterparker
Copy link

Same to me with my repo https://github.com/papyrs/kit

Config

export default defineConfig({
  integrations: [svelte()],
  vite: {
    build: {
      rollupOptions: {
        output: {
          entryFileNames: `build/[name].js`,
          chunkFileNames: `build/chunks/[name].js`,
          assetFileNames: `assets/[name].[ext]`,
        },
      },
    },
  },
});

Output with astro v1.2.5

/dist/
  /assets/
      d-index.css
      d-index-index.css
      index.css

Output with astro v1.6.2

/dist/
  /assets/
       index.css

Note that css is missing - is not bundled at all.

@matthewp
Copy link
Contributor

matthewp commented Nov 9, 2022

Oh no, so sorry to hear that. Our new algorithm does include a hash, so I'm unsure of why exactly it causes this breakage...

@matthewp
Copy link
Contributor

matthewp commented Nov 9, 2022

Oh, maybe I'm confused. Are you saying that you are outputting to omit the hash and that is the reason it breaks?

@Enteleform
Copy link
Contributor Author

@matthewp

Oh, maybe I'm confused. Are you saying that you are outputting to omit the hash and that is the reason it breaks?

Yes; when outputting without hashes, files that used to exist via the previous naming algorithm are no longer present. With the new algorithm, said files end up using firstParentName instead of unique names, and multiple generated files with the same name end up overwriting each other. This seems to occur when there is shared CSS between routes.

@matthewp
Copy link
Contributor

That makes me sense, out of curiosity, why are you omitting the hash? Just for the aesthetic?

We could probably detect that the hash is not being used and omit using the longer algorithm I suppose.

@matthewp matthewp self-assigned this Nov 10, 2022
@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Nov 10, 2022
@Enteleform
Copy link
Contributor Author

@matthewp

out of curiosity, why are you omitting the hash? Just for the aesthetic?

In this particular case, I'm doing it to reduce noise in my Git workflow:

image

I could also see it being useful when using tooling that operates on the files post-build, so that files can be referenced consistently.

@peterpeterparker
Copy link

peterpeterparker commented Nov 10, 2022

out of curiosity, why are you omitting the hash? Just for the aesthetic?

I omit the hash and have a constant name because my users generate full html pages - their blogs - with my editor. In other words I kind of use Astro to generate HTML templates .

e.g. a user publish a blog post /blog1.html and then later /blog2.html. If the first references /index-hash1.css and the second /index.hash2.css - assuming I developed a change in the meantime - both pages might look different. By using a common /index.css both pages will always use the same CSS and look alike.

Of course agree that's not the most common use case 😁

@matthewp
Copy link
Contributor

Ok thanks I'm going to fix this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants