Hello! I'm trying to work with webpack and prisma....
# orm-help
m
Hello! I'm trying to work with webpack and prisma. Need to bundle our Node Typescript code in to Javascript. After running webpack I'm getting the error
Error: PrismaClient is unable to be run in the browser.
. I was reading about that I might need to copy over some binaries using
copy-webpack-plugin
but I'm not really sure on exactly what needs to be copied. Any pointers?
Okay so setting
target: "node"
fixed the issue of getting a browser env. Now seeing this instead.
Wepack config looks like this
Copy code
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const Dotenv = require("dotenv-webpack");

module.exports = {
  target: "node",
  mode: "development",
  resolve: {
    extensions: [".tsx", ".ts", ".js"],
  },
  entry: {
    index: "./index.ts",
  },
  output: {
    path: path.resolve(__dirname),
    filename: "../../packages/RP/index.js",
  },
  devtool: "eval-source-map",
  externalsPresets: { node: true }, // in order to ignore built-in modules like path, fs, etc.
  externals: [
    nodeExternals({
      modulesDir: "../../node_modules",
    }),
  ], // in order to ignore all modules in node_modules folder
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [
          {
            loader: "ts-loader",
            options: { transpileOnly: true },
          },
        ],
        exclude: "/node_modules/",
      },
    ],
  },
  plugins: [
    new Dotenv(),
  ],
};