Switching from angular.json to webpack-obfuscator

Đang mở
#71 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với cấu hình build Angular 8 trong angular.json và ví dụ custom-webpack.config.js, sau đó tái hiện lỗi '..getProjectMetadata' bằng thiết lập đã được báo cáo. Kiểm tra cách @angular-builders/custom-webpack tích hợp browser builder và cách webpack-obfuscator yêu cầu cấu hình entry và output. Công việc được hoàn tất khi bản build production của Angular hoàn thành và cấu hình làm rối mã được áp dụng mà không gặp exception đó.

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

Mô tả

Hello,

I'm very sorry to ask such a basic question but I need guidance. I've got currently in my angular.json for the build:

      "build": {
         "builder": "@angular-devkit/build-angular:browser",
         "options": {
           "outputPath": "dist",
           "index": "src/index.html",
           "main": "src/main.ts",
           "polyfills": "src/polyfills.ts",
           "tsConfig": "src/tsconfig.app.json",
           "assets": [
             "src/favicon.ico",
             "src/assets",
             {
               "glob": "**/*",
               "input": "node_modules/ngx-monaco-editor/assets/monaco",
               "output": "/assets/monaco"
           }


           ],
           "styles": [
             "node_modules/bootstrap/dist/css/bootstrap.min.css",
             "src/styles.css",
             "node_modules/angular-notifier/styles.css",
             "node_modules/primeicons/primeicons.css",
             "node_modules/primeng/resources/themes/nova-dark/theme.css",
             "node_modules/primeng/resources/primeng.min.css"

           ],
           "scripts": [
             "node_modules/jquery/dist/jquery.min.js",
             "node_modules/popper.js/dist/umd/popper.js",
             "node_modules/bootstrap/dist/js/bootstrap.min.js"
           ]
         },
         "configurations": {
           "production": {
             "fileReplacements": [
               {
                 "replace": "src/environments/environment.ts",
                 "with": "src/environments/environment.prod.ts"
               }
             ],
             "optimization": true,
             "outputHashing": "all",
             "sourceMap": false,
             "extractCss": true,
             "namedChunks": false,
             "aot": true,
             "extractLicenses": true,
             "vendorChunk": false,
             "buildOptimizer": true
           }
         }
       },

This is fairly standard; we've not changed much. So firstly I install the custom webpack dependency:

npm i @angular-builders/custom-webpack -D

Then I have to configure the custom-webpack to include the obfuscation so I modify the above to the following:

"build": {
          "builder": "@angular-builders/custom-webpack:browser",
          "options": {
            "customWebpackConfig": {
              "path": "./custom-webpack.config.js",
              "replaceDuplicatePlugins": true
            },
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              {
                "glob": "**/*",
                "input": "node_modules/ngx-monaco-editor/assets/monaco",
                "output": "/assets/monaco"
            }


            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css",
              "node_modules/angular-notifier/styles.css",
              "node_modules/primeicons/primeicons.css",
              "node_modules/primeng/resources/themes/nova-dark/theme.css",
              "node_modules/primeng/resources/primeng.min.css"

            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },

I then reference the obfuscation file custom-webpack.config.js which is as follows:

// webpack.config.js
'use strict';

const JavaScriptObfuscator = require('webpack-obfuscator');

module.exports = {
    entry: {
        'main': "dist/main.js",
    },
    output: {
        path: 'dist',
        filename: '[name].obs.js' // output: abc.js, cde.js
    },
    plugins: [
        new JavaScriptObfuscator({
            rotateUnicodeArray: true
        }, [])
    ]
};

I'm on Angular 8.3.25 but this is giving me 'An unhandled exception occurred: Job name "..getProjectMetadata" does not exist.'.

Again; I'm sorry if this is not specific to this tool but I'm unsure how to get from the angular.json I have now to the obfuscation detailed in the guide?

I'm happy to write this up in a detailed tutorial when done!

Ngôn ngữ chính
TypeScript
Star
930
Fork
92
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của javascript-obfuscator/webpack-obfuscator

Tất cả issue của javascript-obfuscator/webpack-obfuscator

Issue tương tự

Thêm issue về TypeScript

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.