js混淆
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import path from "path";
|
||||
// const { GenerateSW } = require("workbox-webpack-plugin");
|
||||
|
||||
const WebpackObfuscator = require("webpack-obfuscator");
|
||||
const config = {
|
||||
projectName: "cityh5",
|
||||
|
||||
@@ -37,43 +38,25 @@ const config = {
|
||||
chunkFilename: "static/css/[name].[contenthash:8].css",
|
||||
},
|
||||
]);
|
||||
|
||||
// if (
|
||||
// process.env.NODE_ENV === "production" &&
|
||||
// !chain.plugins.has("workbox")
|
||||
// ) {
|
||||
// chain.plugin("workbox").use(GenerateSW, [
|
||||
// {
|
||||
// clientsClaim: true,
|
||||
// skipWaiting: true,
|
||||
// maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB
|
||||
// runtimeCaching: [
|
||||
// {
|
||||
// urlPattern: /.*\.(?:png|jpg|jpeg|svg|gif|ico)/,
|
||||
// handler: "CacheFirst",
|
||||
// options: {
|
||||
// cacheName: "images-cache",
|
||||
// expiration: {
|
||||
// maxEntries: 50,
|
||||
// maxAgeSeconds: 30 * 24 * 60 * 60,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// urlPattern: /.*\.(?:js|css)/,
|
||||
// handler: "StaleWhileRevalidate",
|
||||
// options: {
|
||||
// cacheName: "static-resources",
|
||||
// expiration: {
|
||||
// maxEntries: 50,
|
||||
// maxAgeSeconds: 7 * 24 * 60 * 60,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// ]);
|
||||
// }
|
||||
// js代码混淆
|
||||
chain.plugin("obfuscator").use(WebpackObfuscator, [
|
||||
{
|
||||
rotateStringArray: true,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 0.5, // 降低比例,提高速度
|
||||
compact: true,
|
||||
controlFlowFlattening: false, // 关闭,提高速度
|
||||
deadCodeInjection: false, // 关闭,提高速度
|
||||
debugProtection: false,
|
||||
disableConsoleOutput: true,
|
||||
selfDefending: false, // 关闭,提高速度
|
||||
simplify: true, // 开启简化,提高性能
|
||||
// 禁用对 async/await 的转换
|
||||
target: "browser", // 或设置为适合目标环境的 ECMAScript 版本
|
||||
disableOptimizations: true, // 禁用某些优化来避免处理 async/await
|
||||
},
|
||||
["**/*.js", "!node_modules/**"], // 避免对 node_modules 进行混淆
|
||||
]);
|
||||
chain.module
|
||||
.rule("markdown")
|
||||
.test(/\.md$/)
|
||||
|
||||
Reference in New Issue
Block a user