We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsconfig.json文件配置 { "compilerOptions": { "outDir": "./dist/", "sourceMap": true, "module": "commonjs", "jsx": "react", "target": "es5", "declaration": true, "lib": ["es6", "es7", "dom", "esnext"], "moduleResolution": "node", "forceConsistentCasingInFileNames": true, "noImplicitReturns": true, "noImplicitThis": true, "noImplicitAny": true, "allowSyntheticDefaultImports": true, "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, "removeComments": true }, "include": [ "./src/**/*" ], "exclude": [ "node_modules", "config", "scripts", "acceptance-tests", "webpack", "jest", "dist", "server" ] }
webpack.config.js文件部分配置 { test: /.tsx?$/, use: [ "ts-loader", { loader: 'ui-component-loader', options: { 'lib': 'antd', 'style': 'style/index.css', } } ], include: path.resolve(__dirname, 'node_modules/antd') }, 依赖文件
期望antd按需加载;实际报错,无法解析的文件类型;不加ui-component-loader能正常运行
The text was updated successfully, but these errors were encountered:
include: path.resolve(__dirname, 'node_modules/antd') 需要改成你导入了antd的源码所在,也就是src目录
include: path.resolve(__dirname, 'node_modules/antd')
src
Sorry, something went wrong.
不起作用,打包的时候还是把antd的所有东西都打进来了 我就只引了一个Button组件
我发现在ts中引入antd,不关是解构赋值引入还是单文件引入,都默认从antd的一个dist文件引入,路径不起作用??
这是我的配置,你可以参考下,我是混合使用的,这两种方式都可以按需加载 下面这个图是没有按需加载 估计你配置有些问题
下图是tsconfig配置
你可以试试
No branches or pull requests
tsconfig.json文件配置
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"module": "commonjs",
"jsx": "react",
"target": "es5",
"declaration": true,
"lib": ["es6", "es7", "dom", "esnext"],
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"removeComments": true
},
"include": [
"./src/**/*"
],
"exclude": [
"node_modules",
"config",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"dist",
"server"
]
}
webpack.config.js文件部分配置
{
test: /.tsx?$/,
use: [
"ts-loader",
{
loader: 'ui-component-loader',
options: {
'lib': 'antd',
'style': 'style/index.css',
}
}
],
include: path.resolve(__dirname, 'node_modules/antd')
},
依赖文件
期望antd按需加载;实际报错,无法解析的文件类型;不加ui-component-loader能正常运行
The text was updated successfully, but these errors were encountered: