Open SufyanDahalan opened 5 months ago
Try reordering the plugin? Also, doesn't config.defines
work instead of this plugin?
Reordering the plugins did not have any affect.
config.defines
replaces occurances only in javascript, thus leaving occurances in css files unchanged.
Describe the bug
I am using rollup-replace plugin for statically replace arbitrary strings in my css and js files. It works fine and as expected in js files, however, it does not work at all in css files, specifically in url() statements. The code passed to the rollup-replace plugin has replaced the content of the css
url()
statements with VITE_ASSET placeholders, which is the reason for the plugin not working.I needed to use the experimental
renderBuiltUrl
feature to get my work done. I think that the behaviour or the code sent to the plugin.Expected behaviour is that the plugin is called with the original code, uncensored by any placeholders, so that the replacements can take place correctly. As far as I was able to test, this issue is specific to query parameters in css
url()
statements.Reproduction
https://replit.com/join/aadchyhrjx-sufyandahalan
Steps to reproduce
npm run build
dist/index-[hash].css
does not have the correct parameter placeholder replaced, contrary to the case while usingnpm run dev
.System Info
Used Package Manager
npm
Logs
~/rollup-replace-plugin-VITEASSET-Bug-Reproduction$ npm run build --debug
vite v5.3.1 building for production... [plugin:replace] [plugin replace] @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to
true
, as the next major version will default this option totrue
. ✓ 12 modules transformed. dist/index.html 0.46 kB │ gzip: 0.30 kB dist/assets/index-BBMnZTiw.css 1.30 kB │ gzip: 0.70 kB dist/assets/index-CwLExNcl.js 19.96 kB │ gzip: 8.04 kB ✓ built in 1.48sValidations