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

常用的一些前端配置 #26

Open
vivipure opened this issue Aug 12, 2022 · 1 comment
Open

常用的一些前端配置 #26

vivipure opened this issue Aug 12, 2022 · 1 comment

Comments

@vivipure
Copy link
Owner

别名配置

JS配置

新建 jsconfig.json, 方便编辑器代码跳转,对构建无意义

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "exclude": ["node_modules"],
  "include": ["src/**/*"]
}

TS配置

tsconfig.json 中配置 paths

 "compilerOptions": {
    "paths": {
      "@/*":["./src/*"]
    }
  }

Webpack配置

webpack.config.js 配置 resolve

  resolve: {
        alias: {
            '@': path.resolve('src'),
        },
  },

Vite 配置

vite.config.js中配置 resolve

resolve: {
    alias: {
      "@": path.resolve(__dirname, 'src')
    }
  }

Babel配置(RN使用时)

下载插件babel-plugin-module-resolver,在 babel.config.js中配置

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'module-resolver',
      {
        alias: {
          '@': './src',
        },
      },
    ],
  ],
}
@vivipure
Copy link
Owner Author

vivipure commented Mar 6, 2023

eslint

出现 delete-cr-prettier

在windows 上换行符会出现这个问题,配置 规则即可

 'prettier/prettier': [
      'error',
      {
        endOfLine: 'auto',
      },
],

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