Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.1.7版本的补丁修复摘要 #3

Open
seho-dev opened this issue Dec 8, 2021 · 0 comments
Open

v1.1.7版本的补丁修复摘要 #3

seho-dev opened this issue Dec 8, 2021 · 0 comments

Comments

@seho-dev
Copy link
Collaborator

seho-dev commented Dec 8, 2021

这里更新一下v1.1.7版本升级摘要,主要更新

  1. 修复 lint-staged校验问题
  2. 新增 antdv工程自定义主题色 兼容处理

感谢@joker77877的提醒,vue模板中关于ts的校验有些许问题,具体的讨论在这里:
lint-staged/lint-staged#825
现有工程可以通过以下方式自行修改

.lintstagedrc.js

const fs = require('fs')
const generateTSConfig = (stagedFilenames) => {
  return (type) => {
    const tsconfig = JSON.parse(fs.readFileSync('tsconfig.json', 'utf8'))
    tsconfig.include = stagedFilenames
    fs.writeFileSync('tsconfig.lint.json', JSON.stringify(tsconfig))
    return `${type} --noEmit --project tsconfig.lint.json`
  }
}

module.exports = {
  '*.{ts,tsx}': ['prettier --write', 'eslint --fix', (fileName) => generateTSConfig(fileName)('tsc')],
  '*.vue': ['prettier --write', 'eslint --fix', (fileName) => generateTSConfig(fileName)('vue-tsc')],
  '*.{json,js,jsx}': ['prettier --write', 'eslint --fix']
}

tsconfig.json (可选修改)

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "lib": ["esnext", "dom"],
    "noImplicitAny": true,
    "noImplicitThis": true,
    "paths": {
      "~/*": ["src/*"]
    },
    "types": ["vite/client", "vite-plugin-pages/client", "vite-plugin-vue-layouts/client", "jest"]
  },
  "exclude": ["dist", "node_modules"]
}

关于这个问题“新增 antdv工程自定义主题色 兼容处理”,我们可以这样做:

  1. 升级依赖 "vite-plugin-style-import": "^1.4.0",
  2. 修改vite.config.ts
import styleImport, { AndDesignVueResolve, VantResolve, ElementPlusResolve } from 'vite-plugin-style-import'
  styleImport({
    resolves: [AndDesignVueResolve(), VantResolve(), ElementPlusResolve()]
  }),
  ViteComponents({
    resolvers: [AntDesignVueResolver({ importStyle: 'less' })],
    dts: 'src/components.d.ts'
  }),
@seho-dev seho-dev pinned this issue Dec 8, 2021
@seho-dev seho-dev unpinned this issue Dec 8, 2021
seho-dev added a commit that referenced this issue Dec 8, 2021
seho-dev added a commit that referenced this issue Dec 8, 2021
seho-dev added a commit that referenced this issue Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant