Skip to content

Updating styles affects js file hash#229

Description

@dkornilove

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions