thibaud frere commited on
Commit
92efa50
·
1 Parent(s): 9c2c882
Files changed (3) hide show
  1. app/src/index.html +0 -2
  2. app/webpack.config.js +21 -3
  3. nginx.conf +15 -1
app/src/index.html CHANGED
@@ -1,8 +1,6 @@
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
4
- <script src="distill.bundle.js" type="module" fetchpriority="high" blocking></script>
5
- <script src="main.bundle.js" type="module" fetchpriority="low" defer></script>
6
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
  <meta charset="utf8">
8
  <base target="_blank">
 
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
 
 
4
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
5
  <meta charset="utf8">
6
  <base target="_blank">
app/webpack.config.js CHANGED
@@ -1,6 +1,7 @@
1
  const path = require("path");
2
  const { CleanWebpackPlugin } = require("clean-webpack-plugin");
3
  const CopyPlugin = require("copy-webpack-plugin");
 
4
  const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
5
 
6
  const COLOR_KEYS = ["color", "bgColor", "fillcolor"];
@@ -51,8 +52,9 @@ module.exports = {
51
  main: "./src/index.js",
52
  },
53
  output: {
54
- filename: "[name].bundle.js",
55
  path: path.resolve(__dirname, "dist"),
 
56
  },
57
  module: {
58
  rules: [
@@ -81,12 +83,28 @@ module.exports = {
81
  to: "assets",
82
  },
83
  { from: "src/style.css", to: "style.css" },
84
- { from: "src/bibliography.bib", to: "bibliography.bib" },
85
- { from: "src/index.html", to: "index.html" }
86
  ],
87
  }),
 
 
 
 
 
 
 
 
 
 
 
88
  ],
89
  devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'eval-source-map',
 
 
 
 
 
 
90
  devServer: {
91
  static: "./dist",
92
  open: process.env.NODE_ENV !== 'production',
 
1
  const path = require("path");
2
  const { CleanWebpackPlugin } = require("clean-webpack-plugin");
3
  const CopyPlugin = require("copy-webpack-plugin");
4
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
5
  const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
6
 
7
  const COLOR_KEYS = ["color", "bgColor", "fillcolor"];
 
52
  main: "./src/index.js",
53
  },
54
  output: {
55
+ filename: "[name].[contenthash:8].bundle.js",
56
  path: path.resolve(__dirname, "dist"),
57
+ clean: true,
58
  },
59
  module: {
60
  rules: [
 
83
  to: "assets",
84
  },
85
  { from: "src/style.css", to: "style.css" },
86
+ { from: "src/bibliography.bib", to: "bibliography.bib" }
 
87
  ],
88
  }),
89
+ new HtmlWebpackPlugin({
90
+ template: path.resolve(__dirname, "src/index.html"),
91
+ inject: "body",
92
+ minify: process.env.NODE_ENV === 'production' ? {
93
+ collapseWhitespace: true,
94
+ removeComments: true,
95
+ removeRedundantAttributes: true,
96
+ removeScriptTypeAttributes: true,
97
+ useShortDoctype: true,
98
+ } : false,
99
+ }),
100
  ],
101
  devtool: process.env.NODE_ENV === 'production' ? 'source-map' : 'eval-source-map',
102
+ optimization: {
103
+ splitChunks: {
104
+ chunks: 'all',
105
+ },
106
+ runtimeChunk: 'single',
107
+ },
108
  devServer: {
109
  static: "./dist",
110
  open: process.env.NODE_ENV !== 'production',
nginx.conf CHANGED
@@ -11,11 +11,16 @@ http {
11
  include /etc/nginx/mime.types;
12
  default_type application/octet-stream;
13
 
14
- access_log /tmp/access.log;
 
 
15
  error_log /tmp/error.log;
16
 
17
  sendfile on;
18
  keepalive_timeout 65;
 
 
 
19
 
20
  server {
21
  listen 8080;
@@ -27,5 +32,14 @@ http {
27
  location / {
28
  try_files $uri $uri/ /index.html;
29
  }
 
 
 
 
 
 
 
 
 
30
  }
31
  }
 
11
  include /etc/nginx/mime.types;
12
  default_type application/octet-stream;
13
 
14
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" $status '
15
+ '$body_bytes_sent "$http_referer" "$http_user_agent" "$http_sec_purpose" $request_time';
16
+ access_log /tmp/access.log main;
17
  error_log /tmp/error.log;
18
 
19
  sendfile on;
20
  keepalive_timeout 65;
21
+ gzip on;
22
+ gzip_types text/plain text/css application/javascript application/json image/svg+xml;
23
+ gzip_min_length 1024;
24
 
25
  server {
26
  listen 8080;
 
32
  location / {
33
  try_files $uri $uri/ /index.html;
34
  }
35
+
36
+ location = /health {
37
+ return 200 'ok';
38
+ add_header Content-Type text/plain;
39
+ }
40
+
41
+ location ~* \.(js|css)$ {
42
+ add_header Cache-Control "public, max-age=31536000, immutable";
43
+ }
44
  }
45
  }