-
Create a new TypeScript React project:
npx create-react-app react-chrome-ext --template typescript cd react-chrome-ext
-
Clean up unnecessary files:
- Delete unwanted files to achieve the desired folder structure.
-
Update App.tsx:
- Replace content with a basic Hello World component.
-
Update index.tsx:
- Create a root element in the DOM and append the app to it.
-
Add minimal CSS in App.css:
- Style the App and container elements.
-
Install necessary dependencies:
npm install --save-dev webpack webpack-cli copy-webpack-plugin css-loader html-webpack-plugin ts-node
-
Create webpack.config.js in the root directory and add the configuration.
-
Update package.json with build and watch scripts:
"scripts": { "build": "webpack --config webpack.config.js", "watch": "webpack -w --config webpack.config.js" }
- Create manifest.json in the root directory and add the following content.
-
Run the build command:
npm run build
- Open Chrome and navigate to chrome://extensions.
- Click "Load unpacked" and select the dist directory in your project.
- Test the extension by reloading the Extensions page and clicking the extension icon.