Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit cad1f1b

Browse files
committed
docs: update
1 parent 1d0c484 commit cad1f1b

File tree

2 files changed

+26
-143
lines changed

2 files changed

+26
-143
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Roy Li
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+5-143
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,9 @@
1-
<img src="src/assets/img/icon-128.png" width="64"/>
1+
# a-translator-chrome-extension
22

3-
# Chrome Extension Boilerplate with React 17 and Webpack 5
3+
## 安装
44

5-
[![npm](https://img.shields.io/npm/v/chrome-extension-boilerplate-react)](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
6-
[![npm-download](https://img.shields.io/npm/dw/chrome-extension-boilerplate-react)](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
7-
[![npm](https://img.shields.io/npm/dm/chrome-extension-boilerplate-react)](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
5+
TBD
86

9-
[![dependencies Status](https://david-dm.org/lxieyang/chrome-extension-boilerplate-react/status.svg)](https://david-dm.org/lxieyang/chrome-extension-boilerplate-react)
10-
[![devDependencies Status](https://david-dm.org/lxieyang/chrome-extension-boilerplate-react/dev-status.svg)](https://david-dm.org/lxieyang/chrome-extension-boilerplate-react?type=dev)
7+
## License
118

12-
## Announcements
13-
14-
- **_Recently updated from React ~~16~~ to 17 and Webpack ~~4~~ to 5!_**
15-
- **_Recently added [TypeScript](https://www.typescriptlang.org/) Support!_**
16-
17-
## Features
18-
19-
This is a basic Chrome Extensions boilerplate to help you write modular and modern Javascript code, load CSS easily and [automatic reload the browser on code changes](https://webpack.github.io/docs/webpack-dev-server.html#automatic-refresh).
20-
21-
This boilerplate is updated with:
22-
23-
- [React 17](https://reactjs.org)
24-
- [Webpack 5](https://webpack.js.org/)
25-
- [React Hot Loader](https://github.com/gaearon/react-hot-loader)
26-
- [eslint-config-react-app](https://www.npmjs.com/package/eslint-config-react-app)
27-
- [Prettier](https://prettier.io/)
28-
- [TypeScript](https://www.typescriptlang.org/)
29-
30-
This boilerplate is heavily inspired by and adapted from [https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate), with additional support for React 17 features and Webpack 5.
31-
32-
Please open up an issue to nudge me to keep the npm packages up-to-date. FYI, it takes time to make different packages with different versions work together nicely.
33-
34-
## Installing and Running
35-
36-
### Procedures:
37-
38-
1. Check if your [Node.js](https://nodejs.org/) version is >= **14**.
39-
2. Clone this repository.
40-
3. Change the package's `name`, `description`, and `repository` fields in `package.json`.
41-
4. Change the name of your extension on `src/manifest.json`.
42-
5. Run `npm install` to install the dependencies.
43-
6. Run `npm start`
44-
7. Load your extension on Chrome following:
45-
1. Access `chrome://extensions/`
46-
2. Check `Developer mode`
47-
3. Click on `Load unpacked extension`
48-
4. Select the `build` folder.
49-
8. Happy hacking.
50-
51-
## Structure
52-
53-
All your extension's code must be placed in the `src` folder.
54-
55-
The boilerplate is already prepared to have a popup, an options page, a background page, and a new tab page (which replaces the new tab page of your browser). But feel free to customize these.
56-
57-
## TypeScript
58-
59-
This boilerplate now supports TypeScript! The `Options` Page is implemented using TypeScript. Please refer to `src/pages/Options/` for example usages.
60-
61-
## Webpack auto-reload and HRM
62-
63-
To make your workflow much more efficient this boilerplate uses the [webpack server](https://webpack.github.io/docs/webpack-dev-server.html) to development (started with `npm start`) with auto reload feature that reloads the browser automatically every time that you save some file in your editor.
64-
65-
You can run the dev mode on other port if you want. Just specify the env var `port` like this:
66-
67-
```
68-
$ PORT=6002 npm run start
69-
```
70-
71-
## Content Scripts
72-
73-
Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as [content scripts](https://developer.chrome.com/extensions/content_scripts), but you need to exclude these entry points from hot reloading [(why?)](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/issues/4#issuecomment-261788690). To do so you need to expose which entry points are content scripts on the `webpack.config.js` using the `chromeExtensionBoilerplate -> notHotReload` config. Look the example below.
74-
75-
Let's say that you want use the `myContentScript` entry point as content script, so on your `webpack.config.js` you will configure the entry point and exclude it from hot reloading, like this:
76-
77-
```js
78-
{
79-
80-
entry: {
81-
myContentScript: "./src/js/myContentScript.js"
82-
},
83-
chromeExtensionBoilerplate: {
84-
notHotReload: ["myContentScript"]
85-
}
86-
87-
}
88-
```
89-
90-
and on your `src/manifest.json`:
91-
92-
```json
93-
{
94-
"content_scripts": [
95-
{
96-
"matches": ["https://www.google.com/*"],
97-
"js": ["myContentScript.bundle.js"]
98-
}
99-
]
100-
}
101-
```
102-
103-
## Intelligent Code Completion
104-
105-
Thanks to [@hudidit](https://github.com/lxieyang/chrome-extension-boilerplate-react/issues/4)'s kind suggestions, this boilerplate supports chrome-specific intelligent code completion using [@types/chrome](https://www.npmjs.com/package/@types/chrome). For example:
106-
107-
![intellisense](https://lxieyang.github.io/static/chrome-extension-boilerplate-dev-intellisense-ed9e7c485d3eaf66417e5da4748e2c97.png)
108-
109-
## Packing
110-
111-
After the development of your extension run the command
112-
113-
```
114-
$ NODE_ENV=production npm run build
115-
```
116-
117-
Now, the content of `build` folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the [official guide](https://developer.chrome.com/webstore/publish) to more infos about publishing.
118-
119-
## Secrets
120-
121-
If you are developing an extension that talks with some API you probably are using different keys for testing and production. Is a good practice you not commit your secret keys and expose to anyone that have access to the repository.
122-
123-
To this task this boilerplate import the file `./secrets.<THE-NODE_ENV>.js` on your modules through the module named as `secrets`, so you can do things like this:
124-
125-
_./secrets.development.js_
126-
127-
```js
128-
export default { key: '123' };
129-
```
130-
131-
_./src/popup.js_
132-
133-
```js
134-
import secrets from 'secrets';
135-
ApiCall({ key: secrets.key });
136-
```
137-
138-
:point_right: The files with name `secrets.*.js` already are ignored on the repository.
139-
140-
## Resources:
141-
142-
- [Webpack documentation](https://webpack.js.org/concepts/)
143-
- [Chrome Extension documentation](https://developer.chrome.com/extensions/getstarted)
144-
145-
---
146-
147-
Michael Xieyang Liu | [Website](https://lxieyang.github.io)
9+
[MIT](./LICENSE)

0 commit comments

Comments
 (0)