diff --git a/web/ASC.Web.Editor/package.json b/web/ASC.Web.Editor/package.json index ec9f5378b7..125866316e 100644 --- a/web/ASC.Web.Editor/package.json +++ b/web/ASC.Web.Editor/package.json @@ -4,14 +4,13 @@ "private": true, "homepage": "/products/files/doceditor", "scripts": { - "build-old": "webpack --mode production", "build:test": "webpack --env minimize=false --mode production", "build:test.translation": "webpack --env minimize=false hideText=true --mode production", "clean": "shx rm -rf dist", "deploy": "shx --silent mkdir -p ../../build/deploy/products/ASC.Files/editor && shx cp -r dist/* ../../build/deploy/products/ASC.Files/editor", - "serve": "serve dist -p 5013", "start-prod": "yarn build && node dist/index.js", - "build": "webpack --config webpack.config.js" + "build": "webpack --config webpack.config.js", + "build:server": "webpack --config webpack.server.js --mode production" }, "devDependencies": { "@babel/core": "^7.15.5", @@ -47,4 +46,4 @@ "dependencies": { "express": "^4.17.2" } -} +} \ No newline at end of file diff --git a/web/ASC.Web.Editor/webpack.server.js b/web/ASC.Web.Editor/webpack.server.js index b68d996b86..2b8001275c 100644 --- a/web/ASC.Web.Editor/webpack.server.js +++ b/web/ASC.Web.Editor/webpack.server.js @@ -1,78 +1,18 @@ const path = require("path"); -//const nodeExternals = require("webpack-node-externals"); +const { config } = require("process"); -module.exports = { +config = { + name: "server", entry: "./src/index.js", target: "node", - // externals: [nodeExternals()], mode: "development", output: { - path: path.resolve("dist"), - filename: "index.js", + path: path.resolve(process.cwd(), "dist"), + filename: "server.js", }, module: { rules: [ - { - test: /\.(png|jpe?g|gif|ico)$/i, - type: "asset/resource", - generator: { - filename: "static/images/[hash][ext][query]", - }, - }, - { - test: /\.m?js/, - type: "javascript/auto", - resolve: { - fullySpecified: false, - }, - }, - { - test: /\.react.svg$/, - use: [ - { - loader: "@svgr/webpack", - options: { - svgoConfig: { - plugins: [{ removeViewBox: false }], - }, - }, - }, - ], - }, - { test: /\.json$/, loader: "json-loader" }, - { - test: /\.css$/i, - use: ["style-loader", "css-loader"], - }, - { - test: /\.s[ac]ss$/i, - use: [ - // Creates `style` nodes from JS strings - "style-loader", - // Translates CSS into CommonJS - { - loader: "css-loader", - options: { - url: { - filter: (url, resourcePath) => { - // resourcePath - path to css file - - // Don't handle `/static` urls - if (url.startsWith("/static") || url.startsWith("data:")) { - return false; - } - - return true; - }, - }, - }, - }, - // Compiles Sass to CSS - "sass-loader", - ], - }, - { test: /\.(js|jsx)$/, exclude: /node_modules/, @@ -94,3 +34,14 @@ module.exports = { ], }, }; + +module.exports = (env, argv) => { + if (argv.mode === "production") { + process.env.NODE_ENV = "production"; + config.mode = "production"; + } else { + process.env.NODE_ENV = "development"; + } + + return config; +};