Vite v4 to v5 global replacement

bkervaski

Bill Kervaski

Posted on September 13, 2024

Vite v4 to v5 global replacement

Hello!

We're migrating from v4 to v5 and want to use defineConfig for global repalcement and conditional imports:


define: {
        _VERSION_: JSON.stringify(process.env.npm_package_version),
        _PLATFORM_: JSON.stringify('Desktop'),
        _ENGINE_: JSON.stringify('electron'),
},

Enter fullscreen mode Exit fullscreen mode

However, we can't seem to use global repalcements for dynamic imports:

import Tone from './tone/_ENGINE_.js'
import Push from './push/_ENGINE_.js'
Enter fullscreen mode Exit fullscreen mode

We end up with the following error:

Could not resolve "./push/_ENGINE_.js" from "src/js/main.js"
Enter fullscreen mode Exit fullscreen mode

Looking for suggestions, thanks for any help :D

💖 💪 🙅 🚩
bkervaski
Bill Kervaski

Posted on September 13, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related