diff --git a/.dumirc.ts b/.dumirc.ts index 81392343..7d5e2606 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,14 +1,18 @@ import { defineConfig } from 'dumi'; -import path from 'path'; + +const name = 'cascader' + +const isProdSite = + // 不是预览模式 同时是生产环境 + process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production'; export default defineConfig({ - alias: { - 'rc-cascader$': path.resolve('src'), - 'rc-cascader/es': path.resolve('src'), - }, favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], themeConfig: { - name: 'Cascader', + name, logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', }, + base: isProdSite ? `/${name}/` : '/', + outputPath: '.doc', + publicPath: isProdSite ? `/${name}/` : '/', }); diff --git a/.eslintrc.js b/.eslintrc.js index 6e0fa311..96aae588 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,9 +1,6 @@ -const base = require('@umijs/fabric/dist/eslint'); - module.exports = { - ...base, + extends: [require.resolve('@umijs/fabric/dist/eslint')], rules: { - ...base.rules, 'no-template-curly-in-string': 0, 'prefer-promise-reject-errors': 0, 'react/no-array-index-key': 0, diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml new file mode 100644 index 00000000..8922209f --- /dev/null +++ b/.github/workflows/site-deploy.yml @@ -0,0 +1,39 @@ +name: Deploy website +on: + push: + tags: + - '*' + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: create package-lock.json + run: npm i --package-lock-only --ignore-scripts + + - name: Install dependencies + run: npm ci + + - name: build Docs + run: npm run docs:build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./.doc + force_orphan: true + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' diff --git a/now.json b/now.json index c7e38d0a..d8278789 100644 --- a/now.json +++ b/now.json @@ -5,10 +5,10 @@ { "src": "package.json", "use": "@now/static-build", - "config": { "distDir": "dist" } + "config": { "distDir": ".doc" } } ], "routes": [ - { "src": "/(.*)", "dest": "/dist/$1" } + { "src": "/(.*)", "dest": "/.doc/$1" } ] } diff --git a/package.json b/package.json index 61f03bc5..651637ec 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,18 @@ "module": "./es/index", "scripts": { "start": "dumi dev", - "build": "dumi build", - "deploy": "UMI_ENV=gh npm run build && gh-pages -d .doc", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d .doc", + "docs:preview": "PREVIEW=true npm run docs:build", "compile": "father build", - "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", - "lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.jsx", + "gh-pages": "npm run docs:build", + "prepublishOnly": "npm run compile && np --yolo --no-publish", + "postpublish": "npm run gh-pages", + "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", + "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", + "pretty-quick": "pretty-quick", "test": "rc-test", - "coverage": "father test --coverage", - "now-build": "npm run build" + "coverage": "rc-test --coverage" }, "devDependencies": { "@rc-component/father-plugin": "^1.0.0", diff --git a/tsconfig.json b/tsconfig.json index 94ced34b..0306fda6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,15 +8,9 @@ "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": [ - "src/*" - ], - "@@/*": [ - "src/.umi/*" - ], - "rc-cascader": [ - "src/index.ts" - ] + "@/*": ["src/*"], + "@@/*": [".dumi/tmp/*"], + "rc-cascader": ["src/index.ts"] } } } \ No newline at end of file