mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 11:12:06 +10:00
fix: build
This commit is contained in:
28
apps/remix/.bin/build.sh
Executable file
28
apps/remix/.bin/build.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on error.
|
||||
set -eo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
start_time=$(date +%s)
|
||||
|
||||
echo "[Build]: Extracting and compiling translations"
|
||||
npm run translate --prefix ../../
|
||||
|
||||
echo "[Build]: Building app"
|
||||
npm run build:app
|
||||
|
||||
echo "[Build]: Building server"
|
||||
npm run build:server
|
||||
|
||||
# Copy over the entry point for the server.
|
||||
cp server/main.js build/server/main.js
|
||||
|
||||
# Copy over all web.js translations
|
||||
cp -r ../../packages/lib/translations build/server/hono/packages/lib/translations
|
||||
|
||||
# Time taken
|
||||
end_time=$(date +%s)
|
||||
|
||||
echo "[Build]: Done in $((end_time - start_time)) seconds"
|
||||
@ -3,9 +3,11 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "cross-env NODE_ENV=production react-router build",
|
||||
"build": "sh .bin/build.sh",
|
||||
"build:app": "cross-env NODE_ENV=production react-router build",
|
||||
"build:server": "cross-env NODE_ENV=production rollup -c rollup.config.mjs",
|
||||
"dev": "react-router dev",
|
||||
"start": "cross-env NODE_ENV=production node dist/server/index.js",
|
||||
"start": "cross-env NODE_ENV=production node build/server/main.js",
|
||||
"clean": "rimraf .react-router && rimraf node_modules",
|
||||
"typecheck": "react-router typegen && tsc",
|
||||
"copy:pdfjs": "node ../../scripts/copy-pdfjs.cjs"
|
||||
@ -55,7 +57,7 @@
|
||||
"react-dropzone": "^14.2.3",
|
||||
"react-hook-form": "^7.43.9",
|
||||
"react-hotkeys-hook": "^4.4.1",
|
||||
"react-icons": "^4.11.0",
|
||||
"react-icons": "^5.4.0",
|
||||
"react-rnd": "^10.4.1",
|
||||
"react-router": "^7.1.5",
|
||||
"recharts": "^2.7.2",
|
||||
@ -69,9 +71,16 @@
|
||||
"uqr": "^0.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.26.7",
|
||||
"@babel/preset-typescript": "^7.26.0",
|
||||
"@lingui/babel-plugin-lingui-macro": "^5.2.0",
|
||||
"@lingui/vite-plugin": "^5.2.0",
|
||||
"@react-router/dev": "^7.1.1",
|
||||
"@react-router/remix-routes-option-adapter": "^7.1.5",
|
||||
"@rollup/plugin-babel": "^6.0.4",
|
||||
"@rollup/plugin-commonjs": "^28.0.2",
|
||||
"@rollup/plugin-node-resolve": "^16.0.0",
|
||||
"@rollup/plugin-typescript": "^12.1.2",
|
||||
"@simplewebauthn/types": "^9.0.1",
|
||||
"@types/formidable": "^2.0.6",
|
||||
"@types/luxon": "^3.3.1",
|
||||
@ -80,8 +89,10 @@
|
||||
"@types/react-dom": "^18",
|
||||
"@types/ua-parser-js": "^0.7.39",
|
||||
"cross-env": "^7.0.3",
|
||||
"esbuild": "0.24.2",
|
||||
"remix-flat-routes": "^0.8.4",
|
||||
"tsx": "^4.11.0",
|
||||
"rollup": "^4.34.5",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "5.6.2",
|
||||
"vite": "^6.1.0",
|
||||
"vite-plugin-babel-macros": "^1.0.6",
|
||||
|
||||
@ -2,6 +2,5 @@ import type { Config } from '@react-router/dev/config';
|
||||
|
||||
export default {
|
||||
appDirectory: 'app',
|
||||
// Server-side render by default, to enable SPA mode set this to `false`
|
||||
ssr: true,
|
||||
} satisfies Config;
|
||||
|
||||
49
apps/remix/rollup.config.mjs
Normal file
49
apps/remix/rollup.config.mjs
Normal file
@ -0,0 +1,49 @@
|
||||
import babel from '@rollup/plugin-babel';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import path from 'node:path';
|
||||
|
||||
/** @type {import('rollup').RollupOptions} */
|
||||
const config = {
|
||||
/**
|
||||
* We specifically target the router.ts instead of the entry point so the rollup doesn't go through the
|
||||
* already prebuilt RR7 server files.
|
||||
*/
|
||||
input: 'server/router.ts',
|
||||
output: {
|
||||
dir: 'build/server/hono',
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
preserveModules: true,
|
||||
preserveModulesRoot: '.',
|
||||
},
|
||||
external: [/node_modules/],
|
||||
plugins: [
|
||||
typescript({
|
||||
// noEmitOnError: true,
|
||||
moduleResolution: 'bundler',
|
||||
include: ['server/**/*', '../../packages/**/*', '../../packages/lib/translations/**/*'],
|
||||
}),
|
||||
resolve({
|
||||
rootDir: path.join(process.cwd(), '../..'),
|
||||
preferBuiltins: true,
|
||||
resolveOnly: [
|
||||
'@documenso/api/*',
|
||||
'@documenso/auth/*',
|
||||
'@documenso/lib/*',
|
||||
'@documenso/trpc/*',
|
||||
],
|
||||
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
||||
}),
|
||||
commonjs(),
|
||||
babel({
|
||||
babelHelpers: 'bundled',
|
||||
extensions: ['.js', '.ts', '.tsx'],
|
||||
presets: ['@babel/preset-typescript'],
|
||||
plugins: ['@lingui/babel-plugin-lingui-macro'],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
24
apps/remix/server/main.js
Normal file
24
apps/remix/server/main.js
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* This is the main entry point for the server which will launch the RR7 application
|
||||
* and spin up auth, api, etc.
|
||||
*
|
||||
* Note:
|
||||
* This file will be copied to the build folder during build time.
|
||||
* Running this file will not work without a build.
|
||||
*/
|
||||
import { serve } from '@hono/node-server';
|
||||
import { serveStatic } from '@hono/node-server/serve-static';
|
||||
import handle from 'hono-react-router-adapter/node';
|
||||
|
||||
import server from './hono/server/router.js';
|
||||
import * as build from './index.js';
|
||||
|
||||
server.use(
|
||||
serveStatic({
|
||||
root: 'build/client',
|
||||
}),
|
||||
);
|
||||
|
||||
const handler = handle(build, server);
|
||||
|
||||
serve({ fetch: handler.fetch, port: 3000 });
|
||||
@ -1,17 +0,0 @@
|
||||
// main.ts
|
||||
import { serve } from '@hono/node-server';
|
||||
import { serveStatic } from '@hono/node-server/serve-static';
|
||||
import handle from 'hono-react-router-adapter/node';
|
||||
|
||||
import server from '.';
|
||||
import * as build from '../build/server';
|
||||
|
||||
server.use(
|
||||
serveStatic({
|
||||
root: './build/client',
|
||||
}),
|
||||
);
|
||||
|
||||
const handler = handle(build, server);
|
||||
|
||||
serve({ fetch: handler.fetch, port: 3000 });
|
||||
@ -72,8 +72,12 @@ app
|
||||
throw new AppError('INVALID_DOCUMENT_FILE');
|
||||
}
|
||||
|
||||
// Todo: Test this.
|
||||
if (!file.name.endsWith('.pdf')) {
|
||||
file.name = `${file.name}.pdf`;
|
||||
Object.defineProperty(file, 'name', {
|
||||
writable: true,
|
||||
value: `${file.name}.pdf`,
|
||||
});
|
||||
}
|
||||
|
||||
const { type, data } = await putFile(file);
|
||||
@ -1,7 +1,7 @@
|
||||
import { getContext } from 'hono/context-storage';
|
||||
import { redirect } from 'react-router';
|
||||
import type { HonoEnv } from 'server';
|
||||
import type { AppContext } from 'server/context';
|
||||
import type { HonoEnv } from 'server/router';
|
||||
|
||||
import type { AppSession } from '@documenso/lib/client-only/providers/session';
|
||||
|
||||
|
||||
@ -10,7 +10,16 @@
|
||||
"rootDirs": [".", "./.react-router/types"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["./app/*"]
|
||||
"~/*": ["./app/*"],
|
||||
"@documenso/api": ["../../packages/api"],
|
||||
"@documenso/assets": ["../../packages/assets"],
|
||||
"@documenso/auth": ["../../packages/auth"],
|
||||
"@documenso/ee": ["../../packages/ee"],
|
||||
"@documenso/lib": ["../../packages/lib"],
|
||||
"@documenso/prisma": ["../../packages/prisma"],
|
||||
"@documenso/trpc": ["../../packages/trpc"],
|
||||
"@documenso/ui": ["../../packages/ui"],
|
||||
"@documenso/tailwind-config": ["../../packages/tailwind-config"]
|
||||
},
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
|
||||
@ -32,49 +32,38 @@ export default defineConfig({
|
||||
lingui(),
|
||||
tsconfigPaths(),
|
||||
serverAdapter({
|
||||
entry: 'server/index.ts',
|
||||
entry: 'server/main.ts',
|
||||
}),
|
||||
],
|
||||
ssr: {
|
||||
noExternal: ['react-dropzone', 'plausible-tracker', 'pdfjs-dist'],
|
||||
external: ['@node-rs/bcrypt'],
|
||||
external: ['@node-rs/bcrypt', '@prisma/client'],
|
||||
},
|
||||
optimizeDeps: {
|
||||
// include: ['react-icons'],
|
||||
exclude: ['@node-rs/bcrypt'],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
https: 'node:https',
|
||||
'.prisma/client/default': '../../node_modules/.prisma/client/default.js',
|
||||
'.prisma/client/index-browser': '../../node_modules/.prisma/client/index-browser.js',
|
||||
},
|
||||
},
|
||||
/**
|
||||
* Throwing shit at a wall to see what sticks for building below onwards.
|
||||
* Note: Re run rollup again to build the server afterwards.
|
||||
*
|
||||
* See rollup.config.mjs which is used for that.
|
||||
*/
|
||||
// resolve: {
|
||||
// alias: {
|
||||
// // https: 'node:https',
|
||||
// // '.prisma/client/default': '../../node_modules/.prisma/client/default.js',
|
||||
// },
|
||||
// },
|
||||
// optimizeDeps: {
|
||||
// include: [],
|
||||
// },
|
||||
// ssr: {
|
||||
// // noExternal: true,
|
||||
// noExternal: [
|
||||
// '@documenso/assets',
|
||||
// '@documenso/ee',
|
||||
// '@documenso/lib',
|
||||
// '@documenso/prisma',
|
||||
// '@documenso/tailwind-config',
|
||||
// '@documenso/trpc',
|
||||
// '@documenso/ui',
|
||||
// ],
|
||||
// },
|
||||
// build: {
|
||||
// rollupOptions: {
|
||||
// external: [
|
||||
// '@node-rs/bcrypt',
|
||||
// '@documenso/pdf-sign',
|
||||
// 'nodemailer',
|
||||
// 'playwright',
|
||||
// '@aws-sdk/cloudfront-signer',
|
||||
// ],
|
||||
// },
|
||||
// },
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: [
|
||||
'@node-rs/bcrypt',
|
||||
'@documenso/pdf-sign',
|
||||
'@aws-sdk/cloudfront-signer',
|
||||
'nodemailer',
|
||||
'playwright',
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user