{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"declaration": true,
"rootDirs": [
"./components",
"./pages",
"./public",
"./styles",
"./utils",
"./types",
"./services"
],
"outDir": "./src",
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules",
"lib"
],
"types": [
"cypress",
"@percy/cypress"
]
},
我想让这个项目成为一个库,可以在任何网站上嵌入对讲按钮。我的前辈建议我通过 yarn build 在 src 文件夹中构建一个包含我所有代码的单个 .ts 文件,但我仍然无法这样做。该项目是使用 NextJS 和 Typescript 编写的。有什么建议吗?下面是项目的示例目录
project
| components
| component 1
| some .ts & .tsx files // including styles.ts file and index.ts
| component 2
| same structure as comp 1
| index.ts // for exporting
| pages
| API
| some .ts files
| _app.tsx & other .tsx files
| public
| font
| some icons & image folder
| service
| folder
| config.ts
| styles
| theme.ts, styles.ts, .css
| types
| some .d.ts & .ts & folder
| utils
| some .ts & folder that contained functions used in this project.
| src
您可以按照 T3 的文档了解其文件夹结构。基本上,
src
文件夹包含所有其他文件夹,例如pages
,styles
,utils
,...
.
├─ public
│ └─ favicon.ico
├─ prisma
│ └─ schema.prisma
├─ src
│ ├─ env.mjs
│ ├─ pages
│ │ ├─ _app.tsx
│ │ ├─ api
│ │ │ ├─ auth
│ │ │ │ └─ [...nextauth].ts
│ │ │ └─ trpc
│ │ │ └─ [trpc].ts
│ │ └─ index.tsx
│ ├─ server
│ │ ├─ auth.ts
│ │ ├─ db.ts
│ │ └─ api
│ │ ├─ routers
│ │ │ └─ example.ts
│ │ ├─ trpc.ts
│ │ └─ root.ts
│ ├─ styles
│ │ └─ globals.css
│ └─ utils
│ └─ api.ts
├─ .env
├─ .env.example
├─ .eslintrc.cjs
├─ .gitignore
├─ next-env.d.ts
├─ next.config.mjs
├─ package.json
├─ postcss.config.cjs
├─ prettier.config.cjs
├─ README.md
├─ tailwind.config.ts
└─ tsconfig.json
更多信息在这里:https://create.t3.gg/en/folder-structure
如果您觉得有帮助,将不胜感激!谢谢!!