How can I tell what environment vue is currently running if there is no * .env.js file?

in my Vue project, there are no dev.env.js and prod.env.js files.

there are only webpack.base.config.js , webpack.dev.config.js and webpack.prod.config.js files:

so now how can I tell what environment vue is currently running?

Mar.10,2021

It's the same thing. dev indicates the development environment configuration. prod
take a look at this Webpack configuration description (including 4)-- pay attention to details

if we need to determine the current environment in webpack, we also need to set process.env.NODE_ENV = 'production', separately, which is what we do on the first line of the corresponding configuration file. You need to determine the need to cooperate with new webpack.DefinePlugin plug-in
in the (vue) section of the business code.

I don't quite understand your problem description. Just looking at the title of your question, you should understand how environment variables relate to webpack, Vue, and js in the project.

path to environment variables: command line command-> Webpack-> various js and Vue files loaded by Webpack

  1. your nodejs run commands such as NODE_ENV=production npm run dev , where NODE_ENV=production is an environment variable, which is generally used to represent the production environment, where npm run dev is to execute the dev item in package.json scripts, usually to run your webpack script, such as webpack-dev-server-- inline-- hot .
  2. webpack receives the command line variable of NODE_ENV=production (obtained by process.env.NODE_ENV) and puts it into the configuration of DefinePlugin, such as

    new webpack.DefinePlugin({
          'process.env': {
            NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
          }
        }),
  3. All vue js loaded by
  4. Webpack can get variable values through process.env.NODE_ENV , such as console.log (process.env.NODE_ENV = 'production')
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c2a783-33176.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c2a783-33176.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?