Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Vite? #107

Open
alexgleason opened this issue Jan 18, 2023 · 4 comments
Open

Usage with Vite? #107

alexgleason opened this issue Jan 18, 2023 · 4 comments

Comments

@alexgleason
Copy link

I'm migrating a legacy React TypeScript project from Webpack to Vite. I have some pretty substantial preval code.

Vite uses Babel internally, so I think it should be possible to use this with Vite. Has anyone succeeded in getting it working?

@lobaak
Copy link

lobaak commented Mar 23, 2023

@alexgleason I was able to get preval working with the following:

import {defineConfig} from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [
    react({
      babel: {
        plugins: ['preval'],
      },
    })
  ],
});

@istonejoeljonsson
Copy link

Can you show any example of how you use this? @lobaak

@ArturBaybulatov
Copy link

@lobaak Hey! Why did you specify react() twice?

@lobaak
Copy link

lobaak commented Jan 17, 2024

@ArturBaybulatov sorry, that is a typo. I've corrected.

@istonejoeljonsson we use the following to get the version of the library package

const version =
    preval`module.exports = process.env.npm_package_version` || '-';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants