Home > Software design >  How to determine if Vue is running via Vite or Webpack in development mode?
How to determine if Vue is running via Vite or Webpack in development mode?

Time:12-24

Vite and Webpack use different strategies to import modules.

I am writting a package that contains Vue files that recursively require components. That logic is different in Vite and in Webpack.

Is there a way to determine if the code is being run in Vite or Webpack from within the component vue file?

I cannot seem to find a way to determine that.

I tried accessing process.env but it doesn't have that info there, i also tried getCurrrentInstance() and analyzed its object, but there is no info there either.

Is it possible to determine?

CodePudding user response:

Using Vite import.meta.env will be defined.

Using Webpack process.env will be defined.

  • Related