Web: Client: Modified production build

This commit is contained in:
Alexey Safronov 2021-03-10 18:31:21 +03:00
parent 6db29575b1
commit bac65c6744
4 changed files with 79 additions and 30 deletions

View File

@ -3,6 +3,7 @@
"version": "0.1.0",
"private": "true",
"homepage": "",
"title": "ONLYOFFICE",
"scripts": {
"start": "webpack-cli serve",
"build": "webpack --mode production",
@ -18,15 +19,18 @@
"@babel/preset-react": "^7.12.10",
"@svgr/webpack": "^5.5.0",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^3.0.0",
"compression-webpack-plugin": "^7.1.2",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^3.6.0",
"html-webpack-plugin": "4.5.0",
"json-loader": "^0.5.7",
"serve": "11.3.2",
"source-map-loader": "^1.1.2",
"style-loader": "1.2.1",
"webpack": "5.14.0",
"webpack-cli": "4.5.0",
"webpack-dev-server": "3.11.2",
"serve": "11.3.2"
"webpack-dev-server": "3.11.2"
},
"dependencies": {
"@babel/runtime": "^7.12.5",

View File

@ -91,12 +91,12 @@
height: 36px;
}
</style>
<title>ONLYOFFICE</title>
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div class="ipl-progress-indicator" id="ipl-progress-indicator"></div>
<div id="temp-content" style="display: none">
<div id="temp-content" style="display: none;">
<header class="temp-header-container">
<div id="burger-loader-svg" class="burger-loader-svg">
<svg
@ -111,7 +111,7 @@
ry="3"
width="24"
height="24"
style="fill: url('#fill0')"
style="fill: url('#fill0');"
></rect>
<defs>
<linearGradient id="fill0">
@ -137,7 +137,7 @@
ry="3"
width="168"
height="24"
style="fill: url('#fill01')"
style="fill: url('#fill01');"
></rect>
<defs>
<linearGradient id="fill01">
@ -165,7 +165,7 @@
r="18"
width="36"
height="36"
style="fill: url('#fill02')"
style="fill: url('#fill02');"
></circle>
<defs>
<linearGradient id="fill02">
@ -194,7 +194,7 @@
width="100%"
height="100%"
clip-path="url(#clip-path1)"
style="fill: url('#fill1')"
style="fill: url('#fill1');"
></rect>
<defs>
<clipPath id="clip-path1">

View File

@ -1,17 +1,23 @@
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack").container
.ModuleFederationPlugin;
const TerserPlugin = require("terser-webpack-plugin");
//const CompressionPlugin = require("compression-webpack-plugin");
const path = require("path");
const pkg = require("./package.json");
const deps = pkg.dependencies;
const homepage = pkg.homepage;
const title = pkg.title;
const config = {
entry: "./src/index",
mode: "development",
devServer: {
contentBase: path.join(__dirname, "public"),
contentBase: [path.join(__dirname, "dist")],
port: 5001,
historyApiFallback: {
// Paths with dots should still use the history fallback.
@ -44,8 +50,10 @@ const config = {
output: {
publicPath: "auto",
chunkFilename: "[id].[contenthash].js",
chunkFilename: "js/[id].[contenthash].js",
assetModuleFilename: "assets/[hash][ext][query]",
path: path.resolve(process.cwd(), "dist"),
filename: "[name].[contenthash].bundle.js",
},
module: {
@ -108,6 +116,7 @@ const config = {
},
plugins: [
new CleanWebpackPlugin(),
new ModuleFederationPlugin({
name: "studio",
filename: "remoteEntry.js",
@ -147,6 +156,19 @@ const config = {
new HtmlWebpackPlugin({
template: "./public/index.html",
publicPath: homepage,
title: title,
}),
new CopyPlugin({
patterns: [
{
from: "public",
globOptions: {
dot: true,
gitignore: true,
ignore: ["**/index.html"],
},
},
],
}),
],
};
@ -154,6 +176,21 @@ const config = {
module.exports = (env, argv) => {
if (argv.mode === "production") {
config.mode = "production";
config.optimization = {
splitChunks: { chunks: "all" },
minimize: true,
minimizer: [new TerserPlugin()],
};
// config.plugins.push(
// new CompressionPlugin({
// filename: "[path][base].gz[query]",
// algorithm: "gzip",
// test: /\.js(\?.*)?$/i,
// threshold: 10240,
// minRatio: 0.8,
// deleteOriginalAssets: true,
// })
// );
} else {
config.devtool = "cheap-module-source-map";
}

View File

@ -3683,9 +3683,9 @@
form-data "^3.0.0"
"@types/node@*", "@types/node@>= 8":
version "14.14.32"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.32.tgz#90c5c4a8d72bbbfe53033f122341343249183448"
integrity sha512-/Ctrftx/zp4m8JOujM5ZhwzlWLx22nbQJiVqz8/zE15gOeEW+uly3FSX4fGFpcfEvFzXcMCJwq9lGVWgyARXhg==
version "14.14.33"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.33.tgz#9e4f8c64345522e4e8ce77b334a8aaa64e2b6c78"
integrity sha512-oJqcTrgPUF29oUP8AsUqbXGJNuPutsetaa9kTQAQce5Lx5dTYWV02ScBiT/k1BX/Z7pKeqedmvp39Wu4zR7N7g==
"@types/normalize-package-data@^2.4.0":
version "2.4.0"
@ -5792,9 +5792,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001181:
version "1.0.30001197"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001197.tgz#47ad15b977d2f32b3ec2fe2b087e0c50443771db"
integrity sha512-8aE+sqBqtXz4G8g35Eg/XEaFr2N7rd/VQ6eABGBmNtcB8cN6qNJhMi6oSFy4UWWZgqgL3filHT8Nha4meu3tsw==
version "1.0.30001198"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001198.tgz#ed2d9b5f060322ba2efa42afdc56dee3255473f4"
integrity sha512-r5GGgESqOPZzwvdLVER374FpQu2WluCF1Z2DSiFJ89KSmGjT0LVKjgv4NcAqHmGWF9ihNpqRI9KXO9Ex4sKsgA==
capture-exit@^2.0.0:
version "2.0.0"
@ -6293,6 +6293,14 @@ compressible@~2.0.14, compressible@~2.0.16:
dependencies:
mime-db ">= 1.43.0 < 2"
compression-webpack-plugin@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-7.1.2.tgz#f9a1ba84d4879693e29726f6884b382940876597"
integrity sha512-9DKNW6ILLjx+bNBoviHDgLx6swBhWWH9ApClC9sTH2NoFfQM47BapQfovCm9zjD9v1uZwInF5a925FB9ErGQeQ==
dependencies:
schema-utils "^3.0.0"
serialize-javascript "^5.0.1"
compression@1.7.3:
version "1.7.3"
resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.3.tgz#27e0e176aaf260f7f2c2813c3e440adb9f1993db"
@ -7558,9 +7566,9 @@ ejs@^3.1.2:
jake "^10.6.1"
electron-to-chromium@^1.3.564, electron-to-chromium@^1.3.649:
version "1.3.683"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.683.tgz#2c9ab53ff5275cf3dd49278af714d0f8975204f7"
integrity sha512-8mFfiAesXdEdE0DhkMKO7W9U6VU/9T3VTWwZ+4g84/YMP4kgwgFtQgUxuu7FUMcvSeKSNhFQNU+WZ68BQTLT5A==
version "1.3.684"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.684.tgz#053fbb0a4b2d5c076dfa6e1d8ecd06a3075a558a"
integrity sha512-GV/vz2EmmtRSvfGSQ5A0Lucic//IRSDijgL15IgzbBEEnp4rfbxeUSZSlBfmsj7BQvE4sBdgfsvPzLCnp6L21w==
element-resize-detector@^1.2.1:
version "1.2.2"
@ -9388,10 +9396,10 @@ hosted-git-info@^2.1.4, hosted-git-info@^2.7.1:
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
hosted-git-info@^3.0.6:
version "3.0.8"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-3.0.8.tgz#6e35d4cc87af2c5f816e4cb9ce350ba87a3f370d"
integrity sha512-aXpmwoOhRBrw6X3j0h5RloK4x1OzsxMPyxqIHyNfSe2pypkVTZFpEiRoSipPEPlMrh0HW/XsjkJ5WgnCirpNUw==
hosted-git-info@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.0.0.tgz#9f06639a90beff66cacae6e77f8387b431d61ddc"
integrity sha512-fqhGdjk4av7mT9fU/B01dUtZ+WZSc/XEXMoLXDVZukiQRXxeHSSz3AqbeWRJHtF8EQYHlAgB1NSAHU0Cm7aqZA==
dependencies:
lru-cache "^6.0.0"
@ -11746,9 +11754,9 @@ map-obj@^2.0.0:
integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk=
map-obj@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5"
integrity sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g==
version "4.2.0"
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.0.tgz#0e8bc823e2aaca8a0942567d12ed14f389eec153"
integrity sha512-NAq0fCmZYGz9UFEQyndp7sisrow4GroyGeKluyKC/chuITZsPyOyC1UJZPJlVFImhXdROIP5xqouRLThT3BbpQ==
map-or-similar@^1.5.0:
version "1.5.0"
@ -12513,11 +12521,11 @@ normalize-package-data@^2.0.0, normalize-package-data@^2.3.0, normalize-package-
validate-npm-package-license "^3.0.1"
normalize-package-data@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-3.0.0.tgz#1f8a7c423b3d2e85eb36985eaf81de381d01301a"
integrity sha512-6lUjEI0d3v6kFrtgA/lOx4zHCWULXsFNIjHolnZCKCTLA6m/G625cdn3O7eNmT0iD3jfo6HZ9cdImGZwf21prw==
version "3.0.1"
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-3.0.1.tgz#98dc56dfe6755d99b1c53f046e1e3d2dde55a1c7"
integrity sha512-D/ttLdxo71msR4FF3VgSwK4blHfE3/vGByz1NCeE7/Dh8reQOKNJJjk5L10mLq9jxa+ZHzT1/HLgxljzbXE7Fw==
dependencies:
hosted-git-info "^3.0.6"
hosted-git-info "^4.0.0"
resolve "^1.17.0"
semver "^7.3.2"
validate-npm-package-license "^3.0.1"