DocSpace-buildtools/web/ASC.Web.Editor/webpack/webpack.server.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

const { merge } = require("webpack-merge");
const baseConfig = require("./webpack.base.js");
const path = require("path");
const DefinePlugin = require("webpack").DefinePlugin;
const TerserPlugin = require("terser-webpack-plugin");
const serverConfig = {
target: "node",
name: "server",
entry: {
server: "./src/server/index.js",
},
output: {
path: path.resolve(process.cwd(), "dist/"),
filename: "[name].js",
libraryTarget: "commonjs2",
chunkFilename: "chunks/[name].js",
},
};
module.exports = (env, argv) => {
if (argv.mode === "production") {
serverConfig.mode = "production";
serverConfig.optimization = {
minimize: !env.minimize,
minimizer: [new TerserPlugin()],
};
} else {
serverConfig.mode = "development";
}
2022-07-19 07:58:50 +00:00
serverConfig.plugins = [
new DefinePlugin({
IS_DEVELOPMENT: argv.mode !== "production",
PORT: process.env.PORT || 5013,
IS_PERSONAL: env.personal || false,
2022-07-19 07:58:50 +00:00
}),
];
return merge(baseConfig, serverConfig);
};