Web: Login: Modified production build

This commit is contained in:
Alexey Safronov 2021-03-10 19:24:15 +03:00
parent 62488521e3
commit 970ec1eecf
3 changed files with 78 additions and 8 deletions

View File

@ -3,6 +3,7 @@
"version": "0.1.0",
"private": "true",
"homepage": "/login",
"title": "ONLYOFFICE",
"scripts": {
"start": "webpack-cli serve",
"build": "webpack --mode production",
@ -19,6 +20,7 @@
"@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",

View File

@ -1,14 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, viewport-fit=cover"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link id="favicon" rel="shortcut icon" href="favicon.ico" />
<link rel="manifest" href="manifest.json" />
<!-- Tell the browser it's a PWA -->
<meta name="mobile-web-app-capable" content="yes" />
<!-- Tell iOS it's a PWA -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="apple-touch-icon" href="appIcon.png" />
<link
href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i"
rel="stylesheet"
type="text/css"
/>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script>
console.log("It's LOGIN INIT");
console.log("It's Login INIT");
</script>
</body>
</html>

View File

@ -3,10 +3,14 @@ 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;
var config = {
mode: "development",
@ -15,7 +19,7 @@ var config = {
devServer: {
publicPath: homepage,
contentBase: [path.join(__dirname, "public")],
contentBase: [path.join(__dirname, "dist")],
contentBasePublicPath: homepage,
port: 5011,
historyApiFallback: {
@ -41,9 +45,11 @@ var config = {
},
output: {
publicPath: "auto", //homepage
chunkFilename: "[id].[contenthash].js",
publicPath: "auto",
chunkFilename: "js/[id].[contenthash].js",
assetModuleFilename: "assets/[hash][ext][query]",
path: path.resolve(process.cwd(), "dist"),
filename: "[name].[contenthash].bundle.js",
},
resolve: {
@ -55,6 +61,10 @@ var config = {
module: {
rules: [
{
test: /\.(png|jpe?g|gif|ico|svg)$/i,
type: "asset/resource",
},
{
test: /\.m?js/,
type: "javascript/auto",
@ -69,7 +79,7 @@ var config = {
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [{ removeViewbox: false }],
plugins: [{ removeViewBox: false }],
},
},
},
@ -134,6 +144,7 @@ var config = {
new HtmlWebpackPlugin({
template: "./public/index.html",
publicPath: homepage,
title: title,
//base: `${homepage}/`,
}),
new CopyPlugin({
@ -154,6 +165,21 @@ var 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";
}