Webpack packaged vue multi-page application, how to choose whether to introduce some statistical codes according to the different development environment

recently, a multi-page application packaging vue is being built with webpack. Some statistical codes (mainly the introduction of js) choose whether to add to the page according to the difference between the test environment and the production environment. The test environment and the production environment have been distinguished by the value of process.env.NODE_ENV, but they still do not know whether to load the statistical js according to the environment

.
new webpack.DefinePlugin({
    "process.env.NODE_ENV": JSON.stringify("test")
})

to put it more generally, I don"t know how to choose whether to load a js based on the value of a variable

Mar.09,2021

in your main.js, judge the NODE_ENV, and then dynamically create the script tag, and add the js you need to introduce

.
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-1ea9299-47d16.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-1ea9299-47d16.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?