Webpack,es6 dynamically selects import according to the environment

for example, when I am using vconsole. Use npm to install the js file import in my entry. I use it in a development environment, but in a production environment I don"t want to package vconsole into my js file.

I can selectively initialize vconsole in the form of environment variables. But as long as the import, the js will be packaged into the final js file.

May.08,2021

you can consider this. Although it will still be packaged, it will only be downloaded if DEBUG is true.

if (process.env.NODE_ENV === "production") {
  vconsole = function mock() { // do nothing };
} else {
  vconsole = require("vconsole");
}
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-1b3d22b-2c374.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-1b3d22b-2c374.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?