Web: Doceditor: modified server config

This commit is contained in:
Artem Tarasov 2022-02-19 01:50:14 +03:00
parent a00a616d9b
commit a72302961d
2 changed files with 19 additions and 69 deletions

View File

@ -4,14 +4,13 @@
"private": true, "private": true,
"homepage": "/products/files/doceditor", "homepage": "/products/files/doceditor",
"scripts": { "scripts": {
"build-old": "webpack --mode production",
"build:test": "webpack --env minimize=false --mode production", "build:test": "webpack --env minimize=false --mode production",
"build:test.translation": "webpack --env minimize=false hideText=true --mode production", "build:test.translation": "webpack --env minimize=false hideText=true --mode production",
"clean": "shx rm -rf dist", "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", "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", "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": { "devDependencies": {
"@babel/core": "^7.15.5", "@babel/core": "^7.15.5",
@ -47,4 +46,4 @@
"dependencies": { "dependencies": {
"express": "^4.17.2" "express": "^4.17.2"
} }
} }

View File

@ -1,78 +1,18 @@
const path = require("path"); const path = require("path");
//const nodeExternals = require("webpack-node-externals"); const { config } = require("process");
module.exports = { config = {
name: "server",
entry: "./src/index.js", entry: "./src/index.js",
target: "node", target: "node",
// externals: [nodeExternals()],
mode: "development", mode: "development",
output: { output: {
path: path.resolve("dist"), path: path.resolve(process.cwd(), "dist"),
filename: "index.js", filename: "server.js",
}, },
module: { module: {
rules: [ 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)$/, test: /\.(js|jsx)$/,
exclude: /node_modules/, 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;
};