UNPKG

react-chrome-extension-cli

Version:

The CLI for your next Chrome Extension using React

95 lines (69 loc) โ€ข 2.47 kB
# React Chrome Extension CLI The CLI next Chrome Extension. ๐Ÿš€ ## Quick Overview ```sh npm install -g react-chrome-extension-cli react-chrome-extension-cli my-extension cd my-extension npm run watch ``` Then follow these instructions to see your extension: 1. Open **chrome://extensions** 2. Check the **Developer mode** checkbox 3. Click on the **Load unpacked extension** button 4. Select the folder **my-extension/build** When you're ready to publish to Chrome Web Store, create a minified bundle with `npm run build` and then zip the `build` folder. ### Get Started Immediately You **donโ€™t** need to install or configure Webpack.<br> Webpack comes in preconfigured, so that you can focus on the code. Just create a project, and youโ€™re good to go. ## Creating an Extension ### Installation ```sh npm install -g react-chrome-extension-cli ``` ### Usage ```sh react-chrome-extension-cli <project-name> ``` Example: ```sh react- chrome-extension-cli my-react-extension ``` It will create a directory called `my-extension` inside the current folder. <br> Inside that directory, it will generate the initial project structure and install the transitive dependencies, includes `React`, `Ant` ``` my-extension โ”œโ”€โ”€ README.md โ”œโ”€โ”€ node_modules โ”œโ”€โ”€ package.json โ”œโ”€โ”€ .gitignore โ”œโ”€โ”€ config // Webpack with minimal configurations โ”‚ โ”œโ”€โ”€ paths.js โ”‚ โ”œโ”€โ”€ webpack.common.js โ”‚ โ””โ”€โ”€ webpack.config.js โ”œโ”€โ”€ public โ”‚ โ”œโ”€โ”€ icons โ”‚ โ”‚ โ”œโ”€โ”€ logo.png โ”‚ โ”œโ”€โ”€ *.html // HTML files will vary depending on extension type โ”‚ โ””โ”€โ”€ manifest.json โ””โ”€โ”€ src โ”œโ”€โ”€ *.css // CSS files will vary depending on extension type โ””โ”€โ”€ *.js // JS files will vary depending on extension type ``` Once the installation is done, you can open your project folder: ```sh cd my-extension ``` Inside the newly created project, you can run some built-in commands: ### `npm run watch` ไธ€ๅฎš่ฆ่ฐƒๆ•ดไธบๅผ€ๅ‘่€…ๆจกๅผ ๅฝ“ไฝฟ็”จ `npm run build` ๆ‰“ๅŒ…ๅฎŒๆฏ•๏ผŒๅฏไปฅๅŠ ่ฝฝๅˆฐ chrome ๆต่งˆๅ™จไธญ 1. ๆ‰“ๅผ€ **chrome://extensions** 2. ็กฎไฟๆ‰“ๅผ€ไบ†ๅผ€ๅ‘่€…ๆจกๅผ 3. ็‚นๅ‡ป **Load unpacked extension** ๆŒ‰้’ฎ 4. ้€‰ไธญ **my-extension/build** ็›ฎๅฝ• ### `npm run build` Builds the app for production to the build folder.<br> Zip the build folder and your app is ready to be published on Chrome Web Store.