javascript - 如何防止测试被汇总捆绑?
问题描述
我正在构建一个反应组件包,并希望将我的测试文件夹排除在我从汇总构建的 dist 文件中。
运行后我的文件结构如下所示rollup -c
.
├── dist
│ ├── index.js
│ ├── tests
│ ├── index.test.js
├── src
│ ├── index.tsx
│ ├── tests
│ ├── index.test.tsx
我的汇总配置如下所示:
import typescript from 'rollup-plugin-typescript2'
import pkg from './package.json'
export default {
input: 'src/index.tsx',
output: [
{
file: pkg.main,
format: 'cjs',
exports: 'named',
sourcemap: true,
strict: false
}
],
plugins: [typescript()],
external: ['react', 'react-dom', 'prop-types']
}
dist
运行汇总时,如何将我的测试目录从捆绑到文件中排除?
解决方案
如果您不关心类型检查您的测试文件,则接受的答案有效。如果你这样做,而不是将它们tsconfig.json
排除在rollup.config.js
.
plugins: [
/* for @rollup/plugin-typescript */
typescript({
exclude: ["**/__tests__", "**/*.test.ts"]
})
/* or for rollup-plugin-typescript2 */
typescript({
tsconfigOverride: {
exclude: ["**/__tests__", "**/*.test.ts"]
}
})
]
推荐阅读
- google-apps-script - Google 表格:基于生日的操作
- excel - 带有原始数据表的可滚动表与切片器/过滤器一起使用
- .net-core - 如果以这种方式使用 adddbcontext,dbcontext 会处理和关闭吗?
- amazon-web-services - 我在哪里创建 .ebextensions 以使其在 AWS Elastic Beanstalk 中工作
- android - 如何在android studio Edittext中检查第一个非零字符?
- java - 一个有趣的 cron、bash、perl 和 java 问题
- linux-kernel - 与“记录器”一起运行服务器应用程序进程
- javascript - 在 Acrobat Reader 中使用 Javascript 从 PDF 中提取特定页面
- macos - 如何获取 pdf,并将其中的任何 jpeg2000/jpx/jp2 图像转换为 jpeg 图像?
- sql - python 3 flask如何调试400 Bad Request:浏览器(或代理)发送了一个该服务器无法理解的请求