學習了前端主流的框架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"
}
]
]
複製代碼
項目大體搭建完成後續的一些功能待完善前端