help with excluding a 10mb file from obfuscation
hi guys, i'v been having trouble building my chrome extension ever since i included a 10mb file that contains the data about all event buildings in a video game ... before i was able to dynamically load it, but now dynamic loading doesn't work for me as the game itself changed something, so as a temporary fix i downloaded the file and placed it in /src/js/data/cityEntities.js ... ever since doing that, when i run npm run build-lowtool the build gets stuck at:
❯ npm run build-lowtool
> [email protected] build-lowtool
> webpack --config foe-info-low-webpack.config.js
92% sealing asset processing WebpackObfuscator
while when i revert the inclusion of that file, the build builds succesfully ...
so i'v looked up trough your readme on how to exclude a file from obfuscation, and did exactly that ... but still my build process gets stuck at 92% and takes forever to do it ...
this is my foe-info-low-webpack.config.js
var webpack = require("webpack"),
path = require("path"),
fileSystem = require("fs");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const WebpackExtensionManifestPlugin = require("webpack-extension-manifest-plugin");
const baseManifest = require("./src/chrome/manifest-low.json");
const pkg = require("./package.json");
const TerserPlugin = require("terser-webpack-plugin");
var JavaScriptObfuscator = require("webpack-obfuscator");
var ZipPlugin = require("zip-webpack-plugin");
const PACKAGE_NAME = "LoW-Tool";
const date = new Date().toISOString().substr(0, 10);
// const PUBLIC_PATH = process.env.PUBLIC_PATH || '/';
module.exports = {
mode: "production",
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: 6,
parse: {},
compress: {
pure_funcs: ["console.info", "console.debug"],
},
format: {
comments: false,
},
mangle: true,
module: true,
// Deprecated
output: null,
format: null,
toplevel: false,
nameCache: null,
ie8: false,
keep_classnames: false,
keep_fnames: false,
safari10: false,
},
extractComments: false,
}),
],
},
entry: {
app: "./src/extras/index.js",
options: "./src/js/options.js",
devtools: "./src/js/devtools.js",
popup: "./src/js/popup.js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: path.resolve(__dirname, "/node_modules", "/src/js/data/cityEntities.js"),
// `.swcrc` can be used to configure swc
},
{
test: /\.(sa|sc|c)ss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader", "sass-loader"],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ["file-loader"],
},
],
},
output: {
filename: "[name].js",
chunkFilename: "[name].js",
path: path.resolve(__dirname, "build/" + PACKAGE_NAME),
publicPath: "/",
},
plugins: [
new MiniCssExtractPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
}),
new webpack.ProgressPlugin(),
// clean the build folder
new CleanWebpackPlugin({
verbose: true,
cleanStaleWebpackAssets: true,
}),
new webpack.DefinePlugin({
// Definitions...
EXT_NAME: JSON.stringify(PACKAGE_NAME),
DEV: false,
}),
new HtmlWebpackPlugin({
title: PACKAGE_NAME,
manifest: "manifest.json",
filename: "panel.html",
template: "./src/chrome/panel.html",
chunks: ["app"],
hash: true,
}),
new HtmlWebpackPlugin({
title: PACKAGE_NAME,
filename: "options.html",
template: "./src/chrome/options.html",
chunks: ["options"],
}),
new HtmlWebpackPlugin({
title: PACKAGE_NAME,
filename: "popup.html",
template: "./src/chrome/popup.html",
chunks: ["popup"],
}),
new HtmlWebpackPlugin({
title: PACKAGE_NAME,
filename: "devtools.html",
template: "./src/chrome/devtools.html",
chunks: ["devtools"],
}),
new CopyPlugin({
patterns: [
{
from: "node_modules/webextension-polyfill/dist/browser-polyfill.min.js",
},
{ from: "./src/i18n", to: "i18n" },
{ from: "./src/icons/common", to: "icons" },
{ from: "./src/icons/foe-info-low", to: "icons" },
{ from: "src/images/logo90.png", to: "icons/" },
],
}),
new WebpackExtensionManifestPlugin({
config: {
base: baseManifest,
extend: {
version: pkg.version,
name: PACKAGE_NAME,
short_name: PACKAGE_NAME,
},
},
}),
new JavaScriptObfuscator(
{
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
disableConsoleOutput: true,
identifierNamesGenerator: "hexadecimal",
log: false,
numbersToExpressions: true,
renameGlobals: true,
rotateStringArray: true,
selfDefending: true,
shuffleStringArray: true,
simplify: true,
splitStrings: true,
splitStringsChunkLength: 10,
stringArray: true,
stringArrayEncoding: ["base64"],
stringArrayThreshold: 0.75,
transformObjectKeys: true,
unicodeEscapeSequence: false,
},
["excluded_bundle_name.js"]
),
new ZipPlugin({
// OPTIONAL: defaults to the Webpack output path (above)
// can be relative (to Webpack output path) or absolute
path: "../",
// OPTIONAL: defaults to the Webpack output filename (above) or,
// if not present, the basename of the path
filename: PACKAGE_NAME + "_" + pkg.version + "_" + date + ".zip",
}),
],
resolve: {
extensions: [".tsx", ".ts", ".js"],
fallback: {
fs: false,
},
},
};
I'd appreciate any help making the build process actually work, did i exclude /src/js/data/cityEntities.js the proper way?