React +ts + babel+webpack

babel

@babel/preset-typescript 专门处理ts

javascript 复制代码
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.8",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",

ts

javascript 复制代码
"@types/react": "^18.0.15",
"@types/react-dom": "^18.2.11",
"@types/react-redux": "^7.1.27",
"typescript": "^4.8.2"

webpack z增加tsx解析

babel.config.json 增加@babel/preset-typescript

javascript 复制代码
{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react",
    "@babel/preset-typescript"
  ]
}

package.json

javascript 复制代码
{
  "name": "my-frame",
  "version": "0.0.1",
  "private": true,
  "homepage": "./",
  "devDependencies": {
    "@babel/cli": "^7.17.6",
    "@babel/core": "^7.17.8",
    "@babel/preset-env": "^7.16.11",
    "@babel/preset-react": "^7.16.7",
    "@babel/preset-typescript": "^7.16.7",
    "@types/react": "^18.0.15",
    "@types/react-dom": "^18.2.11",
    "@types/react-redux": "^7.1.27",
    "babel-loader": "^8.2.4",
    "css-loader": "^6.7.1",
    "css-minimizer-webpack-plugin": "^4.0.0",
    "file-loader": "^6.2.0",
    "html-webpack-plugin": "^5.5.0",
    "less-loader": "^10.2.0",
    "mini-css-extract-plugin": "^2.6.0",
    "pnp-webpack-plugin": "^1.7.0",
    "postcss-flexbugs-fixes": "^5.0.2",
    "postcss-loader": "^6.2.1",
    "postcss-normalize": "^10.0.1",
    "postcss-preset-env": "^7.4.3",
    "postcss-safe-parser": "^6.0.0",
    "resolve-url-loader": "^5.0.0",
    "sass": "^1.49.9",
    "sass-loader": "^12.6.0",
    "sass-resources-loader": "^2.2.4",
    "style-loader": "^3.3.1",
    "terser-webpack-plugin": "^5.3.1",
    "url-loader": "^4.1.1",
    "webpack": "^5.70.0",
    "webpack-bundle-analyzer": "^4.5.0",
    "webpack-cli": "^4.10.0",
    "webpack-dev-server": "^4.7.4",
    "webpack-manifest-plugin": "^5.0.0",
    "webpackbar": "^5.0.2",
    "workbox-webpack-plugin": "^6.5.2"
  },
  "dependencies": {
    "core-js": "^3.21.1",
    "moment": "^2.29.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router": "^6.3.0",
    "react-router-dom": "^6.3.0",
    "typescript": "^4.8.2"
  },
  "scripts": {
    "start": "webpack server --mode=development",
    "build": "npm run clean && webpack --mode=production",
    "clean": "rimraf build/*"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "eslintConfig": {
    "extends": "react-app"
  }
}
相关推荐
好_快几秒前
Lodash源码阅读-memoizeCapped
前端·javascript·源码阅读
好_快1 分钟前
Lodash源码阅读-toString
前端·javascript·源码阅读
好_快3 分钟前
Lodash源码阅读-memoize
前端·javascript·源码阅读
excel15 分钟前
webpack 核心编译器 十四 节
前端
excel22 分钟前
webpack 核心编译器 十三 节
前端
腾讯TNTWeb前端团队7 小时前
helux v5 发布了,像pinia一样优雅地管理你的react状态吧
前端·javascript·react.js
范文杰11 小时前
AI 时代如何更高效开发前端组件?21st.dev 给了一种答案
前端·ai编程
拉不动的猪11 小时前
刷刷题50(常见的js数据通信与渲染问题)
前端·javascript·面试
拉不动的猪11 小时前
JS多线程Webworks中的几种实战场景演示
前端·javascript·面试
FreeCultureBoy12 小时前
macOS 命令行 原生挂载 webdav 方法
前端