Skip to content

Commit

Permalink
chore(build): add nx
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Mar 20, 2024
1 parent cad774c commit 06b2c2e
Show file tree
Hide file tree
Showing 10 changed files with 1,143 additions and 505 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ node_modules
.DS_Store
dist
.cache
.turbo
.nx

tests/server/static
tests/server/static/upload
Expand Down Expand Up @@ -30,3 +32,6 @@ yarn-error.log*
# auto generate file
types/auto-imports.d.ts
types/components.d.ts


.nx/cache
4 changes: 2 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ registry = https://registry.npmmirror.com
# 根据需要提升含有以下的依赖包到根 node_modules 目录下
public-hoist-pattern[]=husky
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=@eslint*
public-hoist-pattern[]=*prettier*
public-hoist-pattern[]=lint-staged
public-hoist-pattern[]=*stylelint*
public-hoist-pattern[]=@commitlint/cli
public-hoist-pattern[]=@commitlint/types
public-hoist-pattern[]=@commitlint*
public-hoist-pattern[]=core-js

# 提升所有依赖到根 node_modules 目录下,相当于 public-hoist-pattern[]=*,与上面一种方式一般二选一使用
Expand Down
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pluginImport from 'eslint-plugin-import';
import { defineFlatConfig } from 'eslint-define-config';
import * as parserTypeScript from '@typescript-eslint/parser';
import pluginTypeScript from '@typescript-eslint/eslint-plugin';
import unusedImports from 'eslint-plugin-unused-imports';

export default defineFlatConfig([
{
Expand Down Expand Up @@ -133,6 +134,7 @@ export default defineFlatConfig([
files: ['**/*.vue', '**/*.?([cm])ts', '**/*.?([cm])tsx'],
plugins: {
import: pluginImport,
'unused-imports': unusedImports,
},
rules: {
'import/first': 'error',
Expand Down Expand Up @@ -170,6 +172,18 @@ export default defineFlatConfig([
pathGroupsExcludedImportTypes: ['type'],
},
],

'unused-imports/no-unused-imports': 'error',
// 如需保存时自动删除未引用代码,可注释掉该规则
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
},
]);
22 changes: 22 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"parallel": 5,
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["default"],
"outputs": ["{projectRoot}/dist"],
"cache": true
},
"test": {
"dependsOn": ["build"],
"inputs": ["default"],
"cache": true
},
"e2e": {
"dependsOn": ["build"],
"inputs": ["default"],
"cache": true
}
}
}
39 changes: 17 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "pnpm nx:build",
"bootstrap": "pnpm install",
"serve": "npm run dev",
"dev": "vite dev",
"build": "rimraf dist && cross-env NODE_ENV=production vite build",
"build:watch": "rimraf dist && cross-env NODE_ENV=production vite build --watch",
"build:pkg": "pnpm -r --filter='./packages/*' run build",
"build:pkg": "pnpm -r --paralle --filter='./packages/*' run build",
"nx:build": "nx run-many -t build --exclude @admin-pkg/components",
"preview": "npm run build --watch && vite preview",
"preview:dist": "vite preview",
"deploy": "bash deploy.sh",
"openapi": "npx tsx openapi.config.ts",
"clean:cache": "npx rimraf node_modules/.cache/ && npx rimraf node_modules/.vite",
"clean:lib": "npx rimraf node_modules packages/*/node_modules",
"format": "prettier --write .",
"lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json --max-warnings 0 && pretty-quick --check --branch main",
"lint:fix": "eslint --fix . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json && pretty-quick --branch main",
"lint": "pnpm lint:eslint && pnpm lint:prettier && pnpm lint:stylelint",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mocks}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged",
"prepare": "husky install",
"prepare": "husky",
"release": "git push && git push origin --tags",
"gen:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
"reinstall": "rimraf pnpm-lock.yaml && rimraf package.lock.json && rimraf node_modules && npm run bootstrap",
Expand Down Expand Up @@ -68,18 +67,19 @@
"xlsx": "~0.18.5"
},
"devDependencies": {
"@admin-pkg/components": "workspace:^",
"@admin-pkg/vite-plugin-msw": "workspace:^",
"@admin-pkg/vite-plugin-tinymce-resource": "workspace:^",
"@admin-pkg/components": "workspace:*",
"@admin-pkg/vite-plugin-msw": "workspace:*",
"@admin-pkg/vite-plugin-tinymce-resource": "workspace:*",
"@commitlint/cli": "~19.2.1",
"@commitlint/config-conventional": "~19.1.0",
"@faker-js/faker": "^8.4.1",
"@iconify-json/ant-design": "^1.1.15",
"@iconify-json/ep": "^1.1.15",
"@iconify/json": "^2.2.191",
"@iconify/json": "^2.2.194",
"@types/crypto-js": "^4.2.2",
"@types/lodash-es": "~4.17.12",
"@types/node": "~20.11.16",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "~7.3.1",
"@typescript-eslint/parser": "~7.3.1",
"@umijs/openapi": "^1.11.1",
Expand All @@ -95,11 +95,12 @@
"eslint-define-config": "~2.1.0",
"eslint-plugin-import": "~2.29.1",
"eslint-plugin-prettier": "~5.1.3",
"eslint-plugin-unused-imports": "^3.1.0",
"eslint-plugin-vue": "~9.23.0",
"husky": "~9.0.11",
"less": "~4.2.0",
"lint-staged": "~15.2.2",
"msw": "^2.2.8",
"msw": "^2.2.9",
"postcss": "~8.4.37",
"postcss-html": "~1.6.0",
"postcss-less": "~6.0.0",
Expand All @@ -116,13 +117,14 @@
"typescript": "~5.4.2",
"unocss": "^0.58.6",
"unplugin-vue-components": "~0.26.0",
"vite": "~5.1.6",
"vite": "~5.2.2",
"vite-plugin-checker": "~0.6.4",
"vite-plugin-inspect": "^0.8.3",
"vite-plugin-mkcert": "^1.17.4",
"vite-plugin-mkcert": "^1.17.5",
"vite-plugin-svg-icons": "~2.0.1",
"vue-eslint-parser": "~9.4.2",
"vue-tsc": "~1.8.27"
"vue-tsc": "~1.8.27",
"nx": "18.1.2"
},
"__npminstall_done": false,
"repository": {
Expand All @@ -141,14 +143,7 @@
],
"license": "MIT",
"target": "web",
"dependenciesMeta": {
"@admin-pkg/vite-plugin-msw": {
"injected": true
}
},
"pnpm": {
"overrides": {
"@babel/helper-module-imports": "~7.22.15"
}
"overrides": {}
}
}
11 changes: 6 additions & 5 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@admin-pkg/components",
"version": "0.0.3",
"version": "0.0.4",
"description": "",
"type": "module",
"module": "./dist/index.es.js",
Expand All @@ -21,8 +21,8 @@
},
"scripts": {
"dev": "vite",
"build": "rimraf dist && vite build && npm run build:dts",
"build:dts": "npx tsc -p tsconfig.dts.json || true"
"build": "vite build && npm run build:dts",
"build:dts": "tsc -p tsconfig.dts.json || true"
},
"keywords": [
"ant-design-vue",
Expand All @@ -46,10 +46,11 @@
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"typescript": "~5.4.2",
"vite": "^5.1.5"
},
"peerDependencies": {
"vue": "^3.4.0",
"vite": "^5.0.0"
"vite": "^5.0.0",
"vue": "^3.4.0"
}
}
3 changes: 1 addition & 2 deletions packages/vite-plugin-msw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@admin-pkg/vite-plugin-msw",
"version": "0.0.7",
"version": "0.0.8",
"type": "module",
"description": "",
"module": "./dist/browser/index.js",
Expand All @@ -17,7 +17,6 @@
}
},
"scripts": {
"prepare": "npm run build",
"dev": "rimraf dist && tsup --watch",
"build": "rimraf dist && tsup"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/vite-plugin-tinymce-resource/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "@admin-pkg/vite-plugin-tinymce-resource",
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"prepare": "npm run build",
"build": "tsc"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit 06b2c2e

Please sign in to comment.