Update nodemon.json & package.json scripts to use tsconfig-paths

This commit is contained in:
Max Schmidt 2023-06-17 12:25:57 +02:00
parent b7f60e1f47
commit f83cb88bfd
4 changed files with 22 additions and 8 deletions

View File

@ -1,4 +1,5 @@
{
"ext": "ts",
"ignore": ["src/types.ts"],
"exec": "yarn generate:types && ts-node src/server.ts"
}

View File

@ -6,11 +6,11 @@
"license": "MIT",
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js build",
"build:server": "tsc",
"build": "yarn build:payload && yarn build:server",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js node dist/server.js",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types"
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts node -r tsconfig-paths/register node_modules/payload/dist/bin/index.js generate:types"
},
"dependencies": {
"cross-env": "^7.0.3",
@ -22,6 +22,7 @@
"@types/express": "^4.17.9",
"nodemon": "^2.0.6",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
}
}

View File

@ -1,13 +1,23 @@
import { buildConfig } from "payload/config";
import path from "path";
import Posts from "src/collections/Posts";
import Users from "src/collections/Users";
import Media from "src/collections/Media";
import Posts from "@/collections/Posts";
import Users from "@/collections/Users";
import Media from "@/collections/Media";
export default buildConfig({
serverURL: process.env.PAYLOAD_URL,
admin: {
user: Users.slug,
webpack: (config) => ({
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve.alias,
"@": path.resolve(__dirname, "./"),
},
},
}),
},
collections: [Posts, Users, Media],
typescript: {

View File

@ -6,11 +6,13 @@
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "./dist",
"baseUrl": ".",
"rootDir": "./src",
"paths": {
"@/*": ["src/*"]
},
"jsx": "react"
},
"ts-node": {
"transpileOnly": true
"transpileOnly": true,
"require": ["tsconfig-paths/register"]
}
}