#Beginner questions about the fresh template installation
21 messages · Page 1 of 1 (latest)
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
@empty dock Is that Payload 2.0? I know it was big in development in 2.0, but they are smaller in production, and it's even smaller in 3.0 with around 412kb total JS in production.
Seems like you're right:
grep '"payload"' package.json
"payload": "^2.0.0",
But how do I install version 3 then? I've used npx create-payload-app@latest as per documentation.
Also it was a dev version built by yarn dev, is it right that for production I should build with yarn build production?
@empty dock Just a warning and Payload 3.0 is still in beta.
But here is the repo to check it out: https://github.com/payloadcms/payload-3.0-demo
Okm but how do I actually run a production version?
I have compiled with yarn build production then entered build directory and started serve -s . as the result getting weird main.js / styles.js as html code of admin area
@empty dock Did you set the .env file with your DB_URI? If you want to start it you run yarn build & yarn start
You should be able to go to /admin to see the payload admin
@empty dock Also remove that image, the IP is still in there
Also it should be accessible on localhost:3000
DATABASE_URI seems like was set during the installation script, it's present in .env.
Good catch!
Ok so there is no command start:
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts nodemon",
"seed": "rm -rf media && cross-env PAYLOAD_SEED=true PAYLOAD_DROP_DATABASE=true PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts ts-node src/server.ts",
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts payload build",
"build:server": "tsc --project tsconfig.server.json",
"build:next": "cross-env PAYLOAD_CONFIG_PATH=dist/payload/payload.config.js NEXT_BUILD=true node dist/server.js",
"build": "cross-env NODE_ENV=production yarn build:payload && yarn build:server && yarn copyfiles && yarn build:next",
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload/payload.config.js NODE_ENV=production node dist/server.js",
"eject": "yarn remove next react react-dom @next/eslint-plugin-next && ts-node eject.ts",
"copyfiles": "copyfiles -u 1 "src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,js}" dist/",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts payload generate:types",
"generate:graphQLSchema": "cross-env PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts payload generate:graphQLSchema",
"lint": "eslint src",
"lint:fix": "eslint --fix --ext .ts,.tsx src",
"payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts payload"
},
I guess yarn serve
@empty dock So that looks like a version 2 package.json, did you really clone that repo? Because they way payload is set up in 3.0 is a bit different.
Also if you have a repo already in payload 2.0 and have a lot of things setup I would not advice to port it just yet.
I have to drop of for sleep.
Thanks for all your help! I have decided to give a try with version 2 and just to learn how to build it into a production.
Seems like its all working now.
But when starting customising the demo project to my needs, I guess it's better to start with version 3 even if it's in beta not to have a need to port everything in the future?
Have a good rest.
Beginner questions about fresh template installation