將.webpackrc 改爲.webpackrc.js而後具體配置css
const config = {}; config.proxy = { "/api": { "target": "http://localhost:7001", "changeOrigin": true, "pathRewrite": { "^/api": "" } } } config.extraBabelPlugins = [ //antd按需加載引入 ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }], //裝飾器語法配置 [ "@babel/plugin-proposal-decorators", { "legacy": true } ] ] export default config;
建個.babelrcreact
1 { 2 "presets": [ 3 "react-app" 4 ], 5 "plugins": [ 6 [ 7 "import", 8 { 9 "libraryName": "antd", 10 "libraryDirectory": "es", 11 "style": "css" // `style: true` 會加載 less 文件 12 } 13 ], 14 [ 15 "@babel/plugin-proposal-decorators", 16 { 17 "legacy": true 18 } 19 ] 20 ] 21 }
裝飾器 語法使用以前 拿antd的包爲例子webpack