在 create-react-app 中使用
打开 访问你的应用。
先参考 入口页面 (html 或 模板) 相关设置,配置你的项目 html 页面。
按需加载
- 然后在项目根目录创建一个 config-overrides.js 用于修改默认配置。
// do stuff with the webpack config...
return config;
};
- 使用 babel-plugin-import, babel-plugin-import 是一个用于按需加载组件代码和样式的 babel 插件(),现在我们尝试安装它并修改 config-overrides.js 文件。
+ const { override, fixBabelImports } = require('customize-cra');
- module.exports = function override(config, env) {
- return config;
- };
+ module.exports = override(
+ libraryName: 'antd-mobile',
+ style: 'css',
+ }),
含 css-moules
和 的 antd-mobile-sample/create-react-app