Use Tarojs compression code in terser
In the environment of taro
Related issue: #142
Phenomenon
For example: .h-4/6,
Solution
Please compress the code and don't use the method in link, it's too old.
Use the taro configuration item in the terser configuration item, see terser configuration item.
The
terserconfiguration only takes effect in production mode. If you are usingwatchmode and want to enableterser, you need to setprocess.env.NODE_ENVtoproduction.
In other words, when developing the watch mode, just set the environment variable NODE_ENV to production.
In addition, you can also use the compression code option within the WeChat developer tools instead of using the webpack plug-in to compress the code.
Configuration reference
{
terser: {
enable: true,
config: {
//Related configuration items
},
},
}
Then if you want it to take effect during development, you need to pass in the NODE_ENV=production environment variable, for example:
{
"scripts":{
"dev:weapp": "cross-env NODE_ENV=production npm run build:weapp -- --watch",
}
}
cross-env If it is not installed, you can install it.