学习了前端主流的框架react基于 react antd 等搭建了一套后台项目的模板Githubcss
# 安装 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
复制代码
# 修改 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"
}
]
]
复制代码
项目大体搭建完成后续的一些功能待完善前端