mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
Use Noto Sans to gracefully handle inserting custom text on PDF's. Previously we were using Helvetica which is a standard PDF font but that would fail for any character that couldn't be encoded in WinANSI. Noto Sans was chosen as it has support for a large number of languages and glyphs with challenges now being adding support for CJK glyphs.
101 lines
2.6 KiB
JavaScript
101 lines
2.6 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const { version } = require('./package.json');
|
||
const { withAxiom } = require('next-axiom');
|
||
|
||
const ENV_FILES = ['.env', '.env.local', `.env.${process.env.NODE_ENV || 'development'}`];
|
||
|
||
ENV_FILES.forEach((file) => {
|
||
require('dotenv').config({
|
||
path: path.join(__dirname, `../../${file}`),
|
||
});
|
||
});
|
||
|
||
// !: This is a temp hack to get caveat working without placing it back in the public directory.
|
||
// !: By inlining this at build time we should be able to sign faster.
|
||
const FONT_CAVEAT_BYTES = fs.readFileSync(
|
||
path.join(__dirname, '../../packages/assets/fonts/caveat.ttf'),
|
||
);
|
||
|
||
const FONT_NOTO_SANS_BYTES = fs.readFileSync(
|
||
path.join(__dirname, '../../packages/assets/fonts/noto-sans.ttf'),
|
||
);
|
||
|
||
/** @type {import('next').NextConfig} */
|
||
const config = {
|
||
output: process.env.DOCKER_OUTPUT ? 'standalone' : undefined,
|
||
experimental: {
|
||
outputFileTracingRoot: path.join(__dirname, '../../'),
|
||
serverComponentsExternalPackages: ['@node-rs/bcrypt', '@documenso/pdf-sign', 'playwright'],
|
||
serverActions: {
|
||
bodySizeLimit: '50mb',
|
||
},
|
||
},
|
||
reactStrictMode: true,
|
||
transpilePackages: [
|
||
'@documenso/assets',
|
||
'@documenso/ee',
|
||
'@documenso/lib',
|
||
'@documenso/prisma',
|
||
'@documenso/tailwind-config',
|
||
'@documenso/trpc',
|
||
'@documenso/ui',
|
||
],
|
||
env: {
|
||
APP_VERSION: version,
|
||
NEXT_PUBLIC_PROJECT: 'web',
|
||
FONT_CAVEAT_URI: `data:font/ttf;base64,${FONT_CAVEAT_BYTES.toString('base64')}`,
|
||
FONT_NOTO_SANS_URI: `data:font/ttf;base64,${FONT_NOTO_SANS_BYTES.toString('base64')}`,
|
||
},
|
||
modularizeImports: {
|
||
'lucide-react': {
|
||
transform: 'lucide-react/dist/esm/icons/{{ kebabCase member }}',
|
||
},
|
||
},
|
||
webpack: (config, { isServer }) => {
|
||
// fixes: Module not found: Can’t resolve ‘../build/Release/canvas.node’
|
||
if (isServer) {
|
||
config.resolve.alias.canvas = false;
|
||
}
|
||
|
||
return config;
|
||
},
|
||
async rewrites() {
|
||
return [
|
||
{
|
||
source: '/ingest/:path*',
|
||
destination: 'https://eu.posthog.com/:path*',
|
||
},
|
||
];
|
||
},
|
||
async redirects() {
|
||
return [
|
||
{
|
||
permanent: true,
|
||
source: '/documents/:id/sign',
|
||
destination: '/sign/:token',
|
||
has: [
|
||
{
|
||
type: 'query',
|
||
key: 'token',
|
||
},
|
||
],
|
||
},
|
||
{
|
||
permanent: true,
|
||
source: '/documents/:id/signed',
|
||
destination: '/sign/:token',
|
||
has: [
|
||
{
|
||
type: 'query',
|
||
key: 'token',
|
||
},
|
||
],
|
||
},
|
||
];
|
||
},
|
||
};
|
||
|
||
module.exports = withAxiom(config);
|