From 354d1161f356dad0ef8c7d0fbb7e646b377c6af6 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 11 Sep 2021 16:46:40 -0500 Subject: [PATCH] Use Webpack to copy static folder --- next.config.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 next.config.js diff --git a/next.config.js b/next.config.js new file mode 100644 index 0000000..dfdbd5d --- /dev/null +++ b/next.config.js @@ -0,0 +1,28 @@ +const path = require("path") +const CopyPlugin = require("copy-webpack-plugin") + +module.exports = { + // target: "serverless", + // future: { + // webpack5: true, + // }, + webpack: function (config, { dev, isServer }) { + // Fixes npm packages that depend on `fs` module + if (!isServer) { + config.resolve.fallback.fs = false + } + // Copy files to serverless functions + if (!dev) { + config.plugins.push( + new CopyPlugin({ + patterns: [{ + from: 'static', + to: 'static' + }], + }) + ) + } + + return config + }, +}