parcel bundler

main
Nikita Tokarchuk 4 years ago
parent be0a5042c6
commit 2248f47d66
  1. 2
      .gitignore
  2. 62
      make.js
  3. 7055
      package-lock.json
  4. 8
      package.json
  5. 5371
      yarn.lock

2
.gitignore vendored

@ -33,3 +33,5 @@ task2-backend/task2-backend
task3-backend/task3-backend
node_modules/
build/

@ -0,0 +1,62 @@
const Bundler = require('parcel-bundler');
const Path = require('path');
const FS = require('fs');
const Obfuscator = require("javascript-obfuscator");
const module_name = process.argv[2];
if (!module_name) {
throw new Error('no module name');
}
const entryFiles = Path.join(__dirname, module_name, './index.html');
const outDir = Path.join(__dirname, 'build', module_name);
const options = {
outDir: outDir,
cache: false,
watch: false,
minify: true,
hmr: false,
sourceMaps: false,
detailedReport: true,
contentHash: true,
production: true,
};
const obfuscation = { controlFlowFlattening: true };
(async function () {
const bundler = new Bundler(entryFiles, options);
bundler.bundle();
bundler.on('bundled', async (bundle) => {
for (let result of bundle.childBundles) {
if (result.type != 'js') {
continue;
}
await Promise
.resolve()
.then(() => new Promise((res, rej) =>
FS.readFile(result.name, { encoding: 'utf8' }, (err, data) => {
if (err) {
return rej(err);
}
res(Obfuscator.obfuscate(data, obfuscation).getObfuscatedCode())
})))
.then((obfuscated) => new Promise((res, rej) =>
FS.writeFile(result.name, obfuscated, (err) => {
if (err) {
return rej(err);
}
res();
})))
.then(() => console.log(`${result.name} obfuscated`));
}
});
})();

7055
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -4,7 +4,8 @@
"description": "adm-quest",
"scripts": {
"clean": "rimraf build dist .cache",
"build-task1": "parcel build -d build/task1 task1/index.html"
"build-task1": "node make task1",
"build-task2": "node make task2"
},
"repository": {
"type": "git",
@ -17,8 +18,11 @@
},
"homepage": "https://github.com/mainnika/a-quest#readme",
"dependencies": {
"bootstrap": "^4.4.1",
"javascript-obfuscator": "^0.20.4",
"jquery": "^3.4.1",
"parcel-bundler": "^1.12.4",
"parcel-plugin-obfuscate": "^1.0.0",
"popper.js": "^1.16.0",
"rimraf": "^3.0.0"
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save