redhat-developer / try-in-dev-spaces-browser-extension

MIT License
0 stars 4 forks source link

Use yarn, webpack, convert javascript to typescript #10

Closed dkwon17 closed 1 year ago

dkwon17 commented 1 year ago

Signed-off-by: David Kwon dakwon@redhat.com

Part of https://github.com/redhat-developer/try-in-web-ide-browser-extension/issues/6

Before this PR, the project hierarchy is:

try-in-web-ide-browser-extension/
├── README.md
├── manifest.json
├── options.html
├── options.js
├── osio32.png
├── script.js

After this PR, the hierarchy becomes:

try-in-web-ide-browser-extension/
├── README.md
├── manifest.json
├── package.json
├── tsconfig.json
├── webpack.config.js
└── src/
    ├── assets/icons/
    │   └── osio32.png
    ├── options/
    │   ├── options.html
    │   └── options.ts (renamed from options.js)
    └── contentScript/
        └── contentScript.ts (renamed from script.js)

This PR introduces three scripts in package.json:

  "scripts": {
    "build": "webpack --mode=development",
    "build:prod": "webpack --mode=production --node-env=production",
    "watch": "yarn build --watch"
  }

When developing, run yarn run watch. This will generate the dist folder which contains the bundled extension files. The dist folder contents should be sideloaded the the web browser.

The hierarchy of the dist folder:

dist/
├── contentScript.bundle.js
├── manifest.json
├── options.bundle.js
├── options.html
└── osio32.png