生也有涯,知也无涯。这篇文章主要讲述create-react-app项目配置相关的知识,希望能为你提供帮助。
创建项目npx create-react-app 项目名
自定义配置【create-react-app项目配置】安装自定义配置所需插件:yarn add react-app-rewired customize-cra --dev
安装 babel-plugin-import 来加载 antd:yarn add babel-plugin-import --dev
项目根目录新建一个 config-overrides.js
const { override, fixBabelImports, addWebpackAlias } = require('
customize-cra'
)
const path = require('
path'
)
module.exports = override(
// 配置路径别名
addWebpackAlias({
components: path.resolve(__dirname, '
src/components'
),
utils: path.resolve(__dirname, '
src/utils'
),
actions: path.resolve(__dirname, '
src/actions'
)
}),
//按需加载antd
fixBabelImports('
import'
, {
libraryName: '
antd'
,
libraryDirectory: '
es'
,
style: '
css'
})
)
跨域配置运行:
yarn add http-proxy-middleware --dev
在 src 目录下新建 setupProxy.js
const proxy = require('
http-proxy-middleware'
)module.exports = function(app) {
app.use(
proxy('
/api'
, {
target: '
https://gitee.com/api/v5/'
,
changeOrigin: true,
pathRewrite: {
'
^/api'
: '
'
}
})
)
}
使用sass
yarn add node-sass
推荐阅读
- Android Studio 常用应用
- ----uni-app之修改头像----
- com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1035079 -- APPARENT DEADLOCK!!! C
- Android Sqlite 批量插入性能优化
- 微信聊天记录能当做借钱的凭证吗?_微信
- 微信PC版不扫二维码登陆的办法_微信
- 林丹8个避孕套动态表情图_微信
- 宝宝有小情绪!林丹带字表情包大全_微信
- 微信大视频是啥?微信大视频介绍_微信