javascript-obfuscator / javascript-obfuscator/webpack-obfuscator

Exclude files

Aperta
#166 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
928
Fork
92
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hello all,

I have used webpack obfuscator previous version for webpack 4 with laravel mix. Now I have been trying this version and it works great, but when it tried to build the service worker always gives me an error saying that it cant find the self.__manifest. I realized that probably some files are being obfuscated and they should not. So, I decided to exclude the files that I was excluding before, but after trying some things, reading the docs and look to the webpackObfuscatorPlugin class and apply what it looks like its the correct way I am not being able to exclude the files I want.

This is the block of code that I am using:
```
if (mix.inProduction()) {
/**
* PWA code
*/
mix.injectManifest({
swSrc: './resources/js/service-worker.js',
swDest: path.join(`${__dirname}/public`, 'service-worker.js'),
mode: 'production',
});

mix.webpackConfig({
plugins: [
new WebpackObfuscator({
//rotateStringArray: true,
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false,
},
[
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'resources/js/app.js'),
path.join(__dirname, 'resources/js/bootstrap.js'),
path.join(__dirname, 'resources/js/service-worker.js'),
]),
],
});
}
```

Before this I do all the mix.js() to the files that I need for dev and production.

I am missing something important for sure, but can't find what I am doing wrong to exclude those files.

Maybe some mix function as it could be done in the old version?

```
mix.serve('php artisan lang:js')
.obfuscator({
options: {
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: false,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false
},
exclude: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, 'resources/js/app.js'),
path.resolve(__dirname, 'resources/js/bootstrap.js'),
path.resolve(__dirname, 'resources/js/service-worker.js'),
]
});
}
```

Thank you for the help :)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla configurazione di WebpackObfuscator e dalla classe webpackObfuscatorPlugin citate nell’issue, quindi traccia il modo in cui vengono confrontati i percorsi esclusi. Riproduci la build di produzione di Laravel Mix che coinvolge resources/js/service-worker.js, app.js e bootstrap.js. Il lavoro è completato quando i file elencati sono esclusi e la build del service worker termina senza l’errore self.__manifest.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.