1.需要下面的命令
yarn add antd
yarn add @craco/craco
2.安装craco后需要package.json的命令
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test"
},
3.在根目录下创建一个craco.config.js的文件,和package.json同级
const path = require('path');
module.exports = {
webpack: {
alias: {
"@": path.resolve("src"),
"@utils": path.resolve("src/utils"),
}
},
babel: {
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
[
"import",
{
"libraryName": "antd",
"libraryDirectory": "es",
"style": 'css'
}
]
]
},
module:{
rules:[
{
test: /.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader'],
},
]
},
devServer: {
proxy: {
"/api": {
target: 'http://XXXXXXXX:8888',
changeOrigin: true,
pathRewrite: {
"^/api": ""
}
}
}
}
};