Skip to content

Commit fab9dfc

Browse files
committed
init
0 parents  commit fab9dfc

31 files changed

+134396
-0
lines changed

.babelrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": "last 2 versions"
7+
}
8+
],
9+
[
10+
"@babel/preset-react",
11+
{
12+
"runtime": "automatic"
13+
}
14+
],
15+
"@babel/preset-typescript"
16+
],
17+
"plugins": ["@babel/plugin-transform-runtime", "@babel/plugin-syntax-dynamic-import"]
18+
}

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.eslintrc

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"ecmaFeatures": {
5+
"jsx": true
6+
},
7+
"ecmaVersion": 2020,
8+
"sourceType": "module"
9+
},
10+
"settings": {
11+
"react": {
12+
"version": "detect"
13+
}
14+
},
15+
"extends": [
16+
"eslint:recommended",
17+
"plugin:@typescript-eslint/recommended",
18+
"plugin:react/recommended",
19+
"plugin:react-hooks/recommended",
20+
"plugin:prettier/recommended"
21+
],
22+
"plugins": ["simple-import-sort"],
23+
"rules": {
24+
"no-use-before-define": "off",
25+
"@typescript-eslint/no-use-before-define": "off",
26+
"@typescript-eslint/explicit-module-boundary-types": "off",
27+
"@typescript-eslint/no-unused-expressions": "off",
28+
"@typescript-eslint/no-inferrable-types": "off",
29+
"@typescript-eslint/ban-ts-comment": "off",
30+
"@typescript-eslint/no-non-null-assertion": "off",
31+
"@typescript-eslint/no-empty-function": "off",
32+
"react/jsx-uses-react": "off",
33+
"react/react-in-jsx-scope": "off",
34+
"react-hooks/rules-of-hooks": "error",
35+
"react-hooks/exhaustive-deps": "warn",
36+
"simple-import-sort/imports": "warn",
37+
"simple-import-sort/exports": "warn",
38+
"prettier/prettier": [
39+
"warn",
40+
{ "semi": false },
41+
{
42+
"usePrettierrc": true
43+
}
44+
],
45+
"import/no-unresolved": "off",
46+
"max-lines-per-function": "off",
47+
"prefer-const": "warn",
48+
"prefer-template": "off",
49+
"prefer-destructuring": "warn",
50+
"no-console": "off"
51+
},
52+
"overrides": []
53+
}

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
.idea
3+
*.log
4+
appDevConfig
5+
node_modules
6+
dist
7+
output
8+
tsconfig.tsbuildinfo
9+
.vscode

.prettierrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "none",
10+
"bracketSpacing": true,
11+
"jsxBracketSameLine": false,
12+
"arrowParens": "avoid",
13+
"requirePragma": false,
14+
"insertPragma": false,
15+
"proseWrap": "preserve",
16+
"htmlWhitespaceSensitivity": "css",
17+
"endOfLine": "lf"
18+
}

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<p align="center">
2+
<br/>
3+
<img width="150px" src="./src/public/icon.png" />
4+
<h3 align="center">Word hunter</h3>
5+
<p align="center">Discover new english <mark>words</mark> you don't know on any web page</p>
6+
</p>
7+
8+
## How to use
9+
10+
There are three types of words on the web page, **unknown**, **known**, and **known a litte**,
11+
"unknown" and "known a litte" will be highlighted.
12+
13+
> unknown ---> known a little ---> known
14+
15+
At first, all the words on the web page are "unknown" by default. You can hover over the words and mark them as "known", and the words will no longer be highlighted.
16+
17+
<img width="500px" src="./screensnap/screensnap_1.jpg" />
18+
19+
You can also mark it as "known a little". The next time you encounter the same word, it will be highlighted. hover the mouse over the word and the context you marked last time will be displayed.
20+
21+
<img width="500px" src="./screensnap/screensnap_2.jpg" />
22+
23+
After you mark as many words as possible for "known", the words highlighted are those you really don't know, you can find them at a glance.
24+
25+
## How to mark faster
26+
27+
- Mark the really not too familiar words on the page as "known a little"
28+
- Click the icon of extension on the toolbar, then click "set all words as known" button in the pop-up panel.
29+
30+
<img width="300px" src="./screensnap/screensnap_3.jpg" />
31+
32+
This will mark all the "unknown" words on the page as "known", excluding the "known a litte" words.

build/webpack.config.analy.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
2+
import merge from 'webpack-merge'
3+
4+
import prodConfig from './webpack.config.base'
5+
6+
const config = merge(prodConfig, {
7+
plugins: [new BundleAnalyzerPlugin({ analyzerMode: 'static' })]
8+
})
9+
10+
export default config

build/webpack.config.base.ts

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import { ChromeExtensionReloaderWebpackPlugin } from 'chrome-extension-reloader-webpack-plugin'
2+
import { CleanWebpackPlugin } from 'clean-webpack-plugin'
3+
import CopyWebpackPlugin from 'copy-webpack-plugin'
4+
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
5+
import HtmlWebpackPlugin from 'html-webpack-plugin'
6+
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
7+
import path from 'path'
8+
import { Configuration as WebpackConfiguration } from 'webpack'
9+
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server'
10+
11+
import pkg from '../package.json'
12+
interface Configuration extends WebpackConfiguration {
13+
devServer?: WebpackDevServerConfiguration & { progress?: boolean }
14+
}
15+
16+
const chromeMainfestVersion = pkg.chromeExtension['mainifest-version']
17+
18+
const config: Configuration = {
19+
output: {
20+
path: path.resolve(__dirname, '../dist'),
21+
publicPath: '/',
22+
filename: pathData => {
23+
return pathData?.chunk?.name === 'background' && chromeMainfestVersion === 3 ? '[name].js' : 'js/[name].js'
24+
},
25+
hotUpdateChunkFilename: 'hot/[id].[fullhash].hot-update.js',
26+
hotUpdateMainFilename: 'hot/[runtime].[fullhash].hot-update.json'
27+
},
28+
resolve: {
29+
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
30+
alias: {
31+
'@': path.resolve(__dirname, '../src')
32+
}
33+
},
34+
cache: {
35+
type: 'filesystem',
36+
buildDependencies: {
37+
config: [__filename]
38+
}
39+
},
40+
stats: {
41+
hash: true,
42+
assets: false,
43+
modules: false,
44+
children: false
45+
},
46+
module: {
47+
rules: [
48+
{
49+
test: /\.m?js$/,
50+
resolve: {
51+
fullySpecified: false
52+
}
53+
},
54+
{
55+
test: /\.(js|ts)x?$/,
56+
exclude: /(node_modules)/,
57+
use: [
58+
{
59+
loader: 'babel-loader',
60+
options: {
61+
cacheDirectory: true
62+
}
63+
}
64+
]
65+
},
66+
{
67+
test: /\.(le|c)ss$/,
68+
use: [
69+
{
70+
loader: MiniCssExtractPlugin.loader,
71+
options: {
72+
publicPath: '../'
73+
}
74+
},
75+
'css-loader',
76+
// 'postcss-loader',
77+
'less-loader'
78+
]
79+
},
80+
{
81+
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
82+
use: [
83+
{
84+
loader: 'file-loader',
85+
options: {
86+
name: 'fonts/[name].[ext]'
87+
}
88+
}
89+
]
90+
},
91+
{
92+
test: /\.(png|svg|jpg|gif)$/,
93+
exclude: /(node_modules)/,
94+
use: [
95+
{
96+
loader: 'file-loader',
97+
options: {
98+
name: 'img/[name]-[hash:base64:6].[ext]'
99+
}
100+
}
101+
]
102+
}
103+
]
104+
},
105+
plugins: [
106+
new CleanWebpackPlugin(),
107+
new ForkTsCheckerWebpackPlugin(),
108+
new MiniCssExtractPlugin({
109+
filename: 'css/[name].css'
110+
}),
111+
new ChromeExtensionReloaderWebpackPlugin({
112+
autoOpenDebugPages: process.env.OPEN_DEBUG_PAGES === 'true',
113+
manifestPath: [path.resolve(__dirname, '../src/manifest.v3.json')],
114+
entry: {
115+
background: path.resolve(__dirname, '../src/background/index.ts'),
116+
popup: path.resolve(__dirname, '../src/popup/index.tsx'),
117+
options: path.resolve(__dirname, '../src/options/index.tsx'),
118+
contentScriptDirPath: path.resolve(__dirname, '../src/contents')
119+
}
120+
}),
121+
new CopyWebpackPlugin({
122+
patterns: [
123+
{
124+
from: path.resolve(__dirname, '../src/manifest.v3.json'),
125+
to: path.resolve(__dirname, '../dist/manifest.json')
126+
},
127+
{ from: path.resolve(__dirname, '../src/public'), to: path.resolve(__dirname, '../dist/public') }
128+
]
129+
}),
130+
new HtmlWebpackPlugin({
131+
filename: 'popup.html',
132+
chunks: ['popup'],
133+
title: 'popup page'
134+
}),
135+
new HtmlWebpackPlugin({
136+
filename: 'options.html',
137+
chunks: ['options'],
138+
title: 'word book'
139+
}),
140+
chromeMainfestVersion !== 3 &&
141+
new HtmlWebpackPlugin({
142+
filename: 'background.html',
143+
chunks: ['background'],
144+
title: 'background page'
145+
})
146+
].filter(Boolean)
147+
}
148+
149+
export default config

build/webpack.config.dev.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { MiniReactRefreshWebpackPlugin } from '@njzy/mini-react-refresh-webpack-plugin'
2+
import merge from 'webpack-merge'
3+
4+
import baseConfig from './webpack.config.base'
5+
6+
const config = merge(baseConfig, {
7+
mode: 'development',
8+
devServer: {
9+
compress: true,
10+
clientLogLevel: 'silent',
11+
publicPath: '/',
12+
historyApiFallback: true,
13+
progress: true,
14+
overlay: true
15+
},
16+
module: {},
17+
plugins: [new MiniReactRefreshWebpackPlugin({ entryNames: ['popup', 'options'], exclude: [/\/src\/contents\//] })]
18+
})
19+
20+
export default config

build/webpack.config.prod.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
2+
import TerserPlugin from 'terser-webpack-plugin'
3+
import merge from 'webpack-merge'
4+
5+
import baseConfig from './webpack.config.base'
6+
7+
const config = merge(baseConfig, {
8+
mode: 'production',
9+
optimization: {
10+
minimize: true,
11+
minimizer: [new TerserPlugin(), new CssMinimizerPlugin({})]
12+
}
13+
})
14+
15+
export default config

0 commit comments

Comments
 (0)