sveltejs / sapper

The next small thing in web development, powered by Svelte
https://sapper.svelte.dev
MIT License
7k stars 434 forks source link

Restore hashing of all CSS file names (#1716) #1717

Closed fivemru closed 3 years ago

fivemru commented 3 years ago

Explicitly use hash in rollup-plugin-css-chunks:

chunkFileNames: '[name]-[hash].css',
entryFileNames: '[name]-[hash].css'

fix #1716

Before submitting the PR, please make sure you do the following

Tests

benmccann commented 3 years ago

I would expect this to be specified in Rollup's output.entryFileNames and then all plugins should use that instead of needing to specify it on a per-plugin basis

fivemru commented 3 years ago

I would expect this to be specified in Rollup's output.entryFileNames and then all plugins should use that instead of needing to specify it on a per-plugin basis

The point is that config.client.output() contains the .js extension in the entryFileNames and chunkFileNames fields. https://github.com/sveltejs/sapper/blob/3c01d9300839358e01387c388527f3ec14b0e35b/src/config/rollup.ts#L20 Just replace .js with .css I think it will not be completely predictable behavior.

Now the css file names are completely dependent on the defaults in rollup-plugin-css-chunks, due to their change in version 2.0.0 this bug occurred.

As noted at https://github.com/sveltejs/sapper/blob/3003e980a3cc1db233409a95e9559537e0b2cce8/src/core/create_compilers/RollupCompiler.ts#L163 it is most likely correct to put this in an external plugin.

This pull request simply restores the behavior of version 0.28.10.

istarkov commented 3 years ago

Please release.