Update yatai web server webpack config
const path = require("path");
-const spawnSync = require("child_process").spawnSync;
-const webpack = require("webpack");
const { CheckerPlugin } = require("awesome-typescript-loader");
-// Patch fs with graceful-fs for CopyWebpackPlugin to correctly copy node_modules
-// in order to avoid "Error: EMFILE: too many open files, open.." in large project
-const fs = require("fs");
-const gracefulFs = require("graceful-fs");
-gracefulFs.gracefulify(fs);
-
-const rootDir = fs.realpathSync(process.cwd());
-
-const nodeModulesPath = path.resolve(rootDir, "node_modules");
-const nodeModules = fs.readdirSync(nodeModulesPath).reduce((acc, mod) => {
- if (mod !== ".bin") {
- // eslint-disable-next-line no-param-reassign
- acc[mod] = `commonjs ${mod}`;
- }
- return acc;
-}, {});
-
-module.exports = (settings) => {
- // <option>=<default-value> (overwriting with 'settings' param)
- const {
- // Don't attempt to continue if there are any errors.
- bail = true,
- // Generate sourcemap file
- sourcemap = true,
- // webpack mode https://webpack.js.org/concepts/mode/
- mode = "development",
- } = settings || {};
-
- return {
- mode: mode,
- bail: bail,
+module.exports = {
+ // webpack is only used for production build in BentoML
+ mode: "production", // "production" | "development" | "none"
target: "node",
+ bail: true, // Don't attempt to continue if there are any errors.
node: {
console: true,
global: false,
@@ -44,9 +15,9 @@ module.exports = (settings) => {
__filename: false,
__dirname: false,
},
- entry: path.resolve(rootDir, "src/index.ts"),
+ entry: path.resolve(__dirname, "src/index.ts"),
output: {
- path: path.resolve(rootDir, "dist"),
+ path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
libraryTarget: "commonjs2",
},
@@ -58,12 +29,12 @@ module.exports = (settings) => {
extensions: [".ts", ".js", ".tsx"],
modules: ["node_modules"],
},
- devtool: sourcemap ? "source-map" : false,
+ devtool: false,
module: {
rules: [
{
test: /\.ts|\.tsx$/,
- include: [path.resolve(rootDir, "src")],
+ include: [path.resolve(__dirname, "src")],
loader: "awesome-typescript-loader",
},
],
@@ -80,4 +51,3 @@ module.exports = (settings) => {
chunkModules: false,
},
};
-};
