base on react-scripts-ts@2.13.0
create a new project with create-react-app
create-react-app myapp --scripts-version=react-scripts-ts-antd
// source
import { Card } from 'antd';
// output
import Card from 'antd/lib/card';
import Card from 'antd/lib/card/style/index.less';
You can rewire your webpack configurations without eject.
// You can get all default loads
const { loaders } = require('react-scripts-ts-antd');
scss and lessless-loader for less.scss.tsconfig.json.// tsconfig.json
{
"allowSyntheticDefaultImports": "true",
"experimentalDecorators": "true"
}
If you want to customize theme by overriding less variables like below.
// index.less
@import "~antd/dist/antd.less";
@primary-color: #000;
You have imported all styles and ts-import-plugin will import styles again. So you need to reset ts-loader options by modifying config-overrides.js to avoid importing styles twice.
// config-overrides.js
const { getLoader } = require("react-app-rewired");
module.exports = function override(config, env) {
// get tsloader
const tsloader = getLoader(
config.module.rules,
rule => String(rule.test) == String(/\.(ts|tsx)$/)
);
// set new options
tsloader.options = {
transpileOnly: true,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory([
{
libraryName: 'antd',
libraryDirectory: 'lib',
},
{
libraryName: 'antd-mobile',
libraryDirectory: 'lib',
}
])
]
})
}
return config;
};
antd package will be installed automatically.If you need antd-mobile, install it manually.This package includes scripts and configuration used by Create React App.
Please refer to its documentation:
$ claude mcp add react-scripts-ts-antd \
-- python -m otcore.mcp_server <graph>