本文適合閱讀對象:javascript
1.安裝babel-plugin-import:css
npm install babel-plugin-import --save-dev
2.修改config/webpack.config.dev.js
和config/webpack.config.prod.js
:
找到這2個文件,而且在這2個文件中,找到如下部分:java
// Process JS with Babel. { test: /\.(js|jsx|mjs)$/, include: paths.appSrc, loader: require.resolve('babel-loader'), options: { // 加上下面的plugins plugins: [ ['import', { libraryName: 'antd-mobile', style: 'css' }]// antd或antd-mobile ], // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. cacheDirectory: true, }, },