Chrome extension template, using React, Webpack, and Tailwind.
So far, this template does not support Firefox, Safari, or any non chromium-based browsers.
First, download the repo. If you have git
installed run the following command or download a zip.
git clone https://github.com/arakilian0/snipx-template
Then, install dependencies.
cd snipx-template
npm install
Now you should have the code installed. Feel free to continue reading...
The manifest.json file has been abstracted into package.json. It get's bundled in npm run dev
and npm run build
. You can also run it manually:
npm run build --manifest
This template uses several paths throughout the application, that you can easily modify in package.json.
Note: If you update 'config.entry', make sure to update 'nodemonConfig' for npm run dev
to work properly.
// package.json
{
...,
"nodemonConfig": {
"ext": "js, jsx, json, css, html, svg",
"watch": [
"your-new-directory/**/*", // update this too...
"package.json"
]
},
...
}
Note: If you update the 'lib' directory name, make sure to update 'scripts'!
// package.json
{
...,
"scripts": {
"dev": "nodemon ./your-new-directory/build.js",
"build": "node ./your-new-directory/build.js"
},
...
}
Use the following command to run the extension in development mode:
npm run dev
The following command can be used to build the project files for a Chrome extension. The difference between build and dev is simply nodemon. You can refer to scripts in package.json or the code-block above.
npm run build
Optionally, you can pass arguments to the build command. Doing so will cancel the full build and will only run the arguments provided.
Note: Running npm run build
is the same as running npm run build --clean --manifest --webpack
.
Note: Avoid using --zip
with other arguments.
To test it, open Chrome:
To make sure webpack finishes before we zip it, first run the build command:
npm run build
Then zip it.
npm run build --zip
Now we have a zipped version of our build. In Chrome, after activating Developer mode
we can load our extension using Load Unpacked
referencing our ./build folder, or Load Packed
using the generated zip file.
MIT License
Copyright (c) 2023 Michael Arakilian
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.