A Vite plugin for conditionally importing modules based on environment, using file naming conventions (e.g., foo.client.js, foo.server.js). Version 0.1.7 is the current release; development appears to be in early stages. It supports both static and dynamic imports, and is inspired by vite-plugin-iso-import. Unlike build-time environment variable substitution, this plugin allows tree-shaking and import splitting per environment. Requires manual setup of define and currentEnv. Limited ecosystem adoption; use with caution for production.
npm install vite-plugin-conditional-importVerified import paths — ran on the pinned version, not inferred.
Shows Vite config setup with environment variables and the plugin, enabling conditional imports based on client/server environment.
Test thoroughly; consider alternatives like vite-plugin-conditional-compile.
Ensure filename uses lowercase env strings (e.g., foo.client.js, not foo.Client.js).
Always pair plugin's currentEnv with corresponding define entries matching import.meta.env.* names.
Monitor repository for activity; consider forking or using alternative plugins.
Ensure `envs` includes all environments used in filenames: envs: ['client', 'server'].
Verify the file exists at the correct path and the naming convention is strict (e.g., foo.client.js).
Change to `import conditionalImportPlugin from 'vite-plugin-conditional-import'`.
No dependency data recorded yet.