there is a requirement to selectively package the code in the js file when packaging using webpack, just like the plug-in packaged by HTML, using the template syntax of the package to selectively package HTML?
there is a requirement to selectively package the code in the js file when packaging using webpack, just like the plug-in packaged by HTML, using the template syntax of the package to selectively package HTML?
provides an idea to use webpack.DefinePlugin ()
to define the env
variable, and then optionally package it according to the variable followed by running the command. For example,
1, define the variable
as shown in the figure, I want to configure the data on the right as a variable, and then go to JS to determine whether or not to indexOf a certain piece of JS code. But after it is packaged, it becomes the format on the left, and there is no way to take .