Skip to content

Commit

Permalink
feat: ✨ add react-intl
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Nov 30, 2022
1 parent af754fb commit d997cb6
Show file tree
Hide file tree
Showing 25 changed files with 2,408 additions and 71 deletions.
34 changes: 17 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ module.exports = {
},
],
'react/display-name': 0,
// 'react/jsx-props-no-spreading': 0,
// 'react/state-in-constructor': 0,
// 'react/static-property-placement': 0,
// // Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
// 'react/destructuring-assignment': 'off',
// 'react/jsx-filename-extension': 'off',
// 'react/no-array-index-key': 'warn',
// 'react-hooks/rules-of-hooks': 'error',
'react/jsx-props-no-spreading': 0,
'react/state-in-constructor': 0,
'react/static-property-placement': 0,
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': 'off',
'react/jsx-filename-extension': 'off',
'react/no-array-index-key': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'off',
// 'react/require-default-props': 0,
// 'react/jsx-fragments': 0,
// 'react/jsx-wrap-multilines': 0,
// 'react/prop-types': 0,
// 'react/forbid-prop-types': 0,
// 'react/sort-comp': 0,
'react/require-default-props': 0,
'react/jsx-fragments': 0,
'react/jsx-wrap-multilines': 0,
'react/prop-types': 0,
'react/forbid-prop-types': 0,
'react/sort-comp': 0,
'react/react-in-jsx-scope': 0,
// 'react/jsx-one-expression-per-line': 0,
// 'react/self-closing-comp': 1,
// 'react/jsx-key': 1,
'react/jsx-one-expression-per-line': 0,
'react/self-closing-comp': 1,
'react/jsx-key': 1,
},
};
15 changes: 15 additions & 0 deletions build/vite/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import react from '@vitejs/plugin-react';
import type { ConfigEnv, PluginOption } from 'vite';

// svg配置
import { configSvgPlugin } from './svg';

export function createVitePlugins(_isBuild = false, _configEnv: ConfigEnv) {
const vitePlugins: PluginOption[] = [];

vitePlugins.push(react());

vitePlugins.push(configSvgPlugin());

return vitePlugins;
}
18 changes: 18 additions & 0 deletions build/vite/plugins/svg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* svg
* https://github.com/anncwb/vite-plugin-svg-icons/blob/main/README.zh_CN.md
*/
import path from 'path';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';

export function configSvgPlugin() {
const svgPlugin = createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
// 压缩配置
// svgoOptions: false,
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
});
return svgPlugin;
}
20 changes: 20 additions & 0 deletions build/vite/resolve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import path from 'path';
import type { ResolveOptions, AliasOptions } from 'vite';

type myResolveOptions = ResolveOptions & { alias?: AliasOptions };

export function createViteResolve(myDirname: string): myResolveOptions {
const viteResolve: myResolveOptions = {
// 引用别名配置
alias: {
// 配置@别名
'@': `${path.resolve(myDirname, 'src')}`,
// 配置#别名
'#': `${path.resolve(myDirname, 'types')}`,
},
// 导入时想要省略的扩展名列表。注意,不 建议忽略自定义导入类型的扩展名(例如:.vue),因为它会干扰 IDE 和类型支持。
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
};

return viteResolve;
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"@ant-design/icons": "^4.8.0",
"@reduxjs/toolkit": "^1.9.0",
"antd": "^5.0.1",
"dayjs": "^1.11.6",
"localforage": "^1.10.0",
"match-sorter": "^6.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "^6.2.1",
"react-redux": "^8.0.5",
"react-router-dom": "^6.4.3",
"sort-by": "^1.2.0"
Expand All @@ -42,8 +44,9 @@
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"typescript": "*",
"vite": "^3.2.3"
"typescript": "^4.9.0",
"vite": "^3.2.3",
"vite-plugin-svg-icons": "^2.0.1"
},
"config": {
"commitizen": {
Expand Down
Loading

0 comments on commit d997cb6

Please sign in to comment.