ElMassimo / vite_ruby

⚡️ Vite.js in Ruby, bringing joy to your JavaScript experience
https://vite-ruby.netlify.app/
MIT License
1.28k stars 117 forks source link

vite.config.ts base: './' not applied #457

Open tomer-zadara opened 4 months ago

tomer-zadara commented 4 months ago

Description 📖

My ruby on rails with vite application, has GUI that can be launched from root URL or from within a reverse-proxy app under a relative URL. In vite.config.ts, after setting configuration base: './', rebuilding vite and assets and restarting GUI service, assets URLs are still absolute, like vite_javascript_tag produces URLs starting with forward slash "/vite/assets/application.xxxx.js" and "/vite/assets/application.xxxx.css", and css url() files are absolute as well. We cannot upgrade vite to version 5, because it requires nodejs 18, which requires glibc 2.28, which requires us to upgrade from ubuntu 18.04 to 20.

Reproduction 🐞

Vite Ruby Info _Run `bin/rake vite:info` and provide the output:_ ``` Running via Spring preloader in process 535 bin/vite present?: true vite_ruby: 3.3.4 vite_rails: 3.0.17 rails: 6.1.7.4 node: v16.20.2 npm: 8.19.4 yarn: 1.22.19 pnpm: ruby: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-linux] installed packages: Zadara-VSA-GUI@ /home/ubuntu/Zadara-VSA-GUI ├─┬ @vitejs/plugin-react-swc@3.6.0 │ └── vite@4.5.2 deduped ├─┬ @vitejs/plugin-react@4.2.1 │ └── vite@4.5.2 deduped ├─┬ vite-plugin-eslint@1.8.1 │ └── vite@4.5.2 deduped ├─┬ vite-plugin-ruby@3.2.2 │ └── vite@4.5.2 deduped └── vite@4.5.2 ```

@ElMassimo GitHub source code shows the prefix_vite_asset function always precedes assets path with forward slash in development: https://github.com/ElMassimo/vite_ruby/blob/c726a1618e2e0658322d1a201759d3447beaa096/vite_ruby/lib/vite_ruby/manifest.rb#L137 Also here: https://github.com/ElMassimo/vite_ruby/blob/981d69de48a018d7fd42612557ec00572f8ef1fa/vite-plugin-ruby/src/config.ts#L104