react antd SPA 管理后台搭建

react antd SPA 管理后台搭建

简介

学习了前端主流的框架react基于 react antd 等搭建了一套后台项目的模板Github

环境

  • OS: Windows10
  • IDE: WebStorm 2019.1.3
  • node: v10.15.0
  • npm: 6.4.1
  • yarn: 1.17.3
  • browser: Chrome76.0.3809.100

依赖

创建项目

# 安装 create-react-app
$ npm install -g create-react-app

# 安装 yarn
$ npm install -g yarn

# 使用 create-react-app 创建脚手架工程
$ create-react-app my-app

# 进入项目目录启动项目访问本地localhost:3000端口
$ yarn start

# 安装依赖
$ yarn add antd react-router-dom less less-loader babel-plugin-import braft-editor

# 暴露项目配置
$ yarn eject

配置项目

Less 解析配置

# 修改 config/webpack.config.js 文件

# 在 45 行添加如下配置
const lessRegex = /\.less$/;
const lessModuleRegex = /\.module\.less$/;

# 在 sassRegex 下方大约 457 行添加配置

// Less 解析配置
{
    test: lessRegex,
    exclude: lessModuleRegex,
    use: getStyleLoaders(
        {
            importLoaders: 2,
            sourceMap: isEnvProduction && shouldUseSourceMap,
        },
        'less-loader'
    ),
    sideEffects: true,
},
{
    test: lessModuleRegex,
    use: getStyleLoaders(
        {
            importLoaders: 2,
            sourceMap: isEnvProduction && shouldUseSourceMap,
            modules: true,
            getLocalIdent: getCSSModuleLocalIdent,
        },
        'less-loader'
    )
},

# 修改 package.json 找到babel 配置项处添加如下配置注意前面的逗号

,
"plugins": [
  [
    "import",
    {
      "libraryName": "antd",
      "style": "css"
    }
  ]
]

项目大致搭建完成后续的一些功能待完善

转载于:https://my.oschina.net/janlle/blog/3099245

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值