javascript-obfuscator / javascript-obfuscator/webpack-obfuscator

Exclude files

Đang mở
#166 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
928
Fork
92
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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 :)

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu với cấu hình WebpackObfuscator và lớp webpackObfuscatorPlugin được đề cập trong issue, sau đó theo dõi cách các đường dẫn bị loại trừ được đối chiếu. Tái hiện bản production build của Laravel Mix liên quan đến resources/js/service-worker.js, app.js và bootstrap.js. Được xem là hoàn tất khi các tệp được liệt kê bị loại trừ và service-worker build hoàn tất mà không có lỗi self.__manifest.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, typescript, webpack
Lĩnh vực
build-system, tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.