Next.js Discord

Discord Forum

Storing custom file in output of vercel build

Unanswered
Spectacled Caiman posted this in #help-forum
Open in Discord
Spectacled CaimanOP
Hi I'm building an api route which will react a file prisma/schema.prisma and return its content. the problem is this file does not gets bundled in output
I read the file in handler like this
    const schemaPath = path.resolve(__dirname, '../../prisma/schema.prisma');
    const schemaContent = readFileSync(schemaPath, 'utf-8');

I also tried copy webpack plugin which works fine for local build but on vercel again the files are not shown
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  images: {
    domains: ['images.unsplash.com'],
  },
  webpack: (config, { isServer }) => {
    if (isServer) {
      config.plugins.push(
        new (require('copy-webpack-plugin'))({
          patterns: [
            {
              from: 'prisma/schema.prisma',
              to: 'prisma/schema.prisma',
            },
          ],
        }),
      );
    }
    return config;
  },
};

module.exports = nextConfig;

how can i include this prisma/schema.prisma file in vercel output so i can read it from api and return its content ?

0 Replies