javascript-obfuscator / javascript-obfuscator/webpack-obfuscator

help with excluding a 10mb file from obfuscation

Aperta
#164 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
928
Fork
92
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

> FoE-Info@0.0.80 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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia esaminando il file segnalato `foe-info-low-webpack.config.js` e la documentazione di `webpack-obfuscator` per verificare come vengono configurate le esclusioni. Il report indica che la build si blocca al 92% durante `WebpackObfuscator` dopo l’aggiunta di `src/js/data/cityEntities.js`; determina se il file viene ancora elaborato e conferma il completamento con successo di `npm run build-lowtool` con quei dati inclusi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, typescript, webpack
Ambito
build-system
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.