Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
246 stars 42 forks source link

Updating styles affects js file hash #229

Open dkornilove opened 1 year ago

dkornilove commented 1 year ago

Using this rollup config, when I do some changes to styles it also affects entry hash. I think it is unexpected behavior as the output js file have its contents untouched

//rollup.config.js
export default [
    {
        input: Object.fromEntries([
            ...glob.sync('src/js/pages/**/index.js').map((file) => 
                path.relative('src/js', file.slice(0, file.length - path.basename(file).length)),
                fileURLToPath(new URL(file, import.meta.url)),
            ]),
        ]),
        output: [
            {
                dir: 'assets/',
                format: 'es',
                plugins: [terser()],
                entryFileNames: '[name]-[hash].js',
                chunkFileNames: 'chunks/[name]-[hash].js',
                assetFileNames: '[name]-[hash][extname]',
            },
        ],
        plugins: [
            styles({ mode: 'extract'  }),
        ],
    },
...

For example my src/js/pages/home/index.js file contains

import '../../../scss/pages/home.scss';

when I edit this scss file i get two new js and css files with new hashes after build in the assets/pages/ folder, but instead i want to only have one new css file with updated hash. So my question is is this expected behavior with my config? What should I do to prevent this behavior? Also sorry for my poor english