webpack.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const path = require('path');
  2. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  3. const WebpackObfuscator = require('webpack-obfuscator');
  4. module.exports = {
  5. mode: 'production',
  6. entry: './info.js',
  7. output: {
  8. path: path.resolve(__dirname),
  9. filename: `bundle.js`,
  10. },
  11. optimization: {
  12. minimizer: [
  13. new UglifyJsPlugin({
  14. uglifyOptions: {
  15. mangle: {
  16. reserved: ['detail', 'search'], // 保留指定函数名
  17. },
  18. compress: {
  19. // 压缩选项配置
  20. unused: true,
  21. dead_code: true,
  22. // drop_console: true,
  23. },
  24. output: {
  25. beautify: false, // 禁用美化输出
  26. },
  27. },
  28. }),
  29. ],
  30. },
  31. plugins: [
  32. new WebpackObfuscator({
  33. rotateUnicodeArray: true,
  34. compact: true,
  35. stringArray: true,
  36. stringArrayEncoding: ['base64'],
  37. }),
  38. ],
  39. devtool: 'source-map'
  40. };