Vite v4 to v5 global replacement

Bill Kervaski - Sep 13 - - Dev Community

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

.
Terabox Video Player