Verified Commit ffffb48d authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Add cache control and robots.txt

parent 5c049ace
......@@ -5,7 +5,27 @@ server {
root /var/www/;
index index.html;
try_files $uri /index.html =404;
gzip_static on;
gunzip on;
}
\ No newline at end of file
location = /service-worker.js {
# Do not allow caching of service worker.
add_header Cache-Control "no-cache";
}
location /assets {
# Allow to cache static assets for one year. Every filename should include a hash!
add_header Cache-Control "public, max-age=31536000, stale-while-revalidate=31536000, stale-if-error=31536000";
}
location ~* \.(.*)\.js$ {
# Allow to cache js files (which have a hash in its filename) for one year.
add_header Cache-Control "public, max-age=31536000, stale-while-revalidate=31536000, stale-if-error=31536000";
}
location / {
# Set default caching to 1 hour (Used for files without hash in its filename).
add_header Cache-Control "public, max-age=3600, stale-while-revalidate=3600, stale-if-error=259200";
try_files $uri /index.html =404;
}
}
......@@ -3161,70 +3161,6 @@
}
}
},
"cache-loader": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/cache-loader/-/cache-loader-2.0.0.tgz",
"integrity": "sha512-zi4iyjWDs80PWRwFfIwcVSgRVIFX2PjyHH8YbsUGFH0U03oA5o80OEryZBCjfN+5tWYHFct1FXha8IhiIhaN6w==",
"dev": true,
"requires": {
"loader-utils": "^1.1.0",
"mkdirp": "^0.5.1",
"neo-async": "^2.5.0",
"schema-utils": "^1.0.0"
},
"dependencies": {
"ajv": {
"version": "6.6.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz",
"integrity": "sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g==",
"dev": true,
"requires": {
"fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"fast-deep-equal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"dev": true
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"schema-utils": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz",
"integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==",
"dev": true,
"requires": {
"ajv": "^6.1.0",
"ajv-errors": "^1.0.0",
"ajv-keywords": "^3.1.0"
}
},
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
"dev": true,
"requires": {
"punycode": "^2.1.0"
}
}
}
},
"call-me-maybe": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz",
......@@ -6467,6 +6403,48 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
"generate-robotstxt": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/generate-robotstxt/-/generate-robotstxt-5.0.7.tgz",
"integrity": "sha512-fSqO9dTnFMZKrnkVInjaMn1uODH2NWq2L1jlY41kLI2AgCwK4gHwAuZi5979kkWKmvf2khbx+Pldl+9vwh2EXg==",
"dev": true,
"requires": {
"cosmiconfig": "^5.0.0",
"fs-extra": "^6.0.0",
"ip-address": "^5.8.6",
"is-absolute-url": "^2.1.0",
"meow": "^5.0.0",
"resolve-from": "^4.0.0"
},
"dependencies": {
"fs-extra": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
"integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
},
"resolve-from": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
"integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
"dev": true
}
}
},
"get-caller-file": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
......@@ -7872,6 +7850,35 @@
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=",
"dev": true
},
"ip-address": {
"version": "5.8.9",
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-5.8.9.tgz",
"integrity": "sha512-7ay355oMN34iXhET1BmCJVsHjOTSItEEIIpOs38qUC23AIhOy+xIPnkrTuEFjeLMrTJ7m8KMXWgWfy/2Vn9sDw==",
"dev": true,
"requires": {
"jsbn": "1.1.0",
"lodash.find": "^4.6.0",
"lodash.max": "^4.0.1",
"lodash.merge": "^4.6.0",
"lodash.padstart": "^4.6.1",
"lodash.repeat": "^4.1.0",
"sprintf-js": "1.1.0"
},
"dependencies": {
"jsbn": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz",
"integrity": "sha1-sBMHyym2GKHtJux56RH4A8TaAEA=",
"dev": true
},
"sprintf-js": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.0.tgz",
"integrity": "sha1-z/yvcC2vZeo5u04PorKZzsGhvkY=",
"dev": true
}
}
},
"ip-regex": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-1.0.3.tgz",
......@@ -7884,6 +7891,12 @@
"integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=",
"dev": true
},
"is-absolute-url": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-2.1.0.tgz",
"integrity": "sha1-UFMN+4T8yap9vnhS6Do3uTufKqY=",
"dev": true
},
"is-accessor-descriptor": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
......@@ -8641,6 +8654,36 @@
"integrity": "sha1-vsECT4WxvZbL6kBbI8FK1kQ6b4E=",
"dev": true
},
"lodash.find": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.find/-/lodash.find-4.6.0.tgz",
"integrity": "sha1-ywcE1Hq3F4n/oN6Ll92Sb7iLE7E=",
"dev": true
},
"lodash.max": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.max/-/lodash.max-4.0.1.tgz",
"integrity": "sha1-hzVWbGGLNan3YFILSHrnllivE2o=",
"dev": true
},
"lodash.merge": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz",
"integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==",
"dev": true
},
"lodash.padstart": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.padstart/-/lodash.padstart-4.6.1.tgz",
"integrity": "sha1-0uPuv/DZ05rVD1y9G1KnvOa7YRs=",
"dev": true
},
"lodash.repeat": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-4.1.0.tgz",
"integrity": "sha1-/H3oEx2MisB+S0n3T/6CnR8r7EQ=",
"dev": true
},
"lodash.template": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz",
......@@ -9356,6 +9399,33 @@
"semver": "^5.3.0"
}
},
"nodeify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz",
"integrity": "sha1-ZKtpp7268DzhB7TwM1yHwLnpGx0=",
"dev": true,
"requires": {
"is-promise": "~1.0.0",
"promise": "~1.3.0"
},
"dependencies": {
"is-promise": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-1.0.1.tgz",
"integrity": "sha1-MVc3YcBX4zwukaq56W2gjO++duU=",
"dev": true
},
"promise": {
"version": "1.3.0",
"resolved": "http://registry.npmjs.org/promise/-/promise-1.3.0.tgz",
"integrity": "sha1-5cyaTIJ45GZP/twBx9qEhCsEAXU=",
"dev": true,
"requires": {
"is-promise": "~1"
}
}
}
},
"normalize-package-data": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz",
......@@ -12558,6 +12628,16 @@
"inherits": "^2.0.1"
}
},
"robotstxt-webpack-plugin": {
"version": "4.0.1",
"resolved": "http://registry.npmjs.org/robotstxt-webpack-plugin/-/robotstxt-webpack-plugin-4.0.1.tgz",
"integrity": "sha512-ZINiN6DdyrFPbAYGrZDXSShfePBCuH2Q8P/tsufs8Yv+M+KpGcj276rcixVOGXrWDiTFuLdkb9bacCjYVepuVw==",
"dev": true,
"requires": {
"generate-robotstxt": "^5.0.0",
"nodeify": "~1.0.0"
}
},
"run-async": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz",
......@@ -16104,6 +16184,37 @@
"tapable": "^1.1.1"
},
"dependencies": {
"ajv": {
"version": "6.8.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.8.1.tgz",
"integrity": "sha512-eqxCp82P+JfqL683wwsL73XmFs1eG6qjw+RD3YHx+Jll1r0jNd4dh8QG9NYAeNGA/hnZjeEDgtTskgJULbxpWQ==",
"dev": true,
"requires": {
"fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==",
"dev": true
},
"cache-loader": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/cache-loader/-/cache-loader-2.0.1.tgz",
"integrity": "sha512-V99T3FOynmGx26Zom+JrVBytLBsmUCzVG2/4NnUKgvXN4bEV42R1ERl1IyiH/cvFIDA1Ytq2lPZ9tXDSahcQpQ==",
"dev": true,
"requires": {
"loader-utils": "^1.1.0",
"mkdirp": "^0.5.1",
"neo-async": "^2.6.0",
"normalize-path": "^3.0.0",
"schema-utils": "^1.0.0"
}
},
"camelcase": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
......@@ -16181,6 +16292,12 @@
"domelementtype": "1"
}
},
"fast-deep-equal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"dev": true
},
"favicons": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/favicons/-/favicons-5.3.0.tgz",
......@@ -16254,6 +16371,21 @@
"core-js": "^2.5.7"
}
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
}
},
"jsontoxml": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/jsontoxml/-/jsontoxml-1.0.1.tgz",
......@@ -16273,6 +16405,17 @@
"strip-bom": "^2.0.0"
}
},
"loader-utils": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz",
"integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==",
"dev": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^2.0.0",
"json5": "^1.0.1"
}
},
"locate-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
......@@ -16291,6 +16434,18 @@
}
}
},
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true
},
"p-limit": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.1.0.tgz",
......@@ -16361,6 +16516,12 @@
}
}
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"read-pkg": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz",
......@@ -16382,6 +16543,17 @@
"read-pkg": "^1.0.0"
}
},
"schema-utils": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz",
"integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==",
"dev": true,
"requires": {
"ajv": "^6.1.0",
"ajv-errors": "^1.0.0",
"ajv-keywords": "^3.1.0"
}
},
"string-width": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
......@@ -16430,6 +16602,15 @@
"xtend": "~4.0.1"
}
},
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
"dev": true,
"requires": {
"punycode": "^2.1.0"
}
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
......
......@@ -2,6 +2,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebappWebpackPlugin = require('webapp-webpack-plugin');
const HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin');
const { GenerateSW } = require('workbox-webpack-plugin');
const RobotstxtPlugin = require('robotstxt-webpack-plugin').default;
const path = require('path');
const config = {
......@@ -12,7 +13,8 @@ const config = {
output: {
path: `${__dirname}/dist`, // `dist` is the destination
publicPath: '/',
filename: 'bundle.js',
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].chunk.js',
},
// To run development server
......@@ -43,11 +45,7 @@ const config = {
},
},
],
include: [
path.resolve(__dirname, './src'),
path.resolve(__dirname, 'node_modules/@material'),
path.resolve(__dirname, 'node_modules/amiv-web-ui-components'),
],
include: [path.resolve(__dirname, './src')],
},
{
test: /src\/content\/amiv\/markdown\/[a-zA-Z\d-]{3,}\.[a-z]{2}\.md$/, // Check for all .md files in /amiv/markdown
......@@ -55,9 +53,9 @@ const config = {
{
loader: 'file-loader', // Writes the generated HTML to a file
options: {
name: '[name].html',
outputPath: 'amiv/',
publicPath: 'amiv/',
name: '[name].[hash].html',
outputPath: 'assets/amiv/',
publicPath: 'assets/amiv/',
},
},
{
......@@ -72,8 +70,8 @@ const config = {
loader: 'file-loader', // Writes the generated HTML to a file
options: {
name: '[name].[hash].html',
outputPath: 'amiv/',
publicPath: 'amiv/',
outputPath: 'assets/amiv/',
publicPath: 'assets/amiv/',
},
},
],
......@@ -86,8 +84,8 @@ const config = {
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: '[name].[hash].[ext]',
outputPath: 'amiv/',
publicPath: 'amiv/',
outputPath: 'assets/amiv/',
publicPath: 'assets/amiv/',
},
},
],
......@@ -100,8 +98,8 @@ const config = {
options: {
limit: 8000, // Convert images < 8kb to base64 strings
name: '[name].[hash].[ext]',
outputPath: 'images',
publicPath: 'images/',
outputPath: 'assets/images',
publicPath: 'assets/images/',
},
},
],
......@@ -148,10 +146,23 @@ const config = {
devtool: 'eval-source-map', // Default development sourcemap
optimization: {
usedExports: true,
sideEffects: true,
splitChunks: {
chunks: 'all',
automaticNameDelimiter: '-',
name: true,
},
},
plugins: [
new RobotstxtPlugin({
policy: [{ userAgent: '*', allow: '/' }],
}),
new WebappWebpackPlugin({
logo: './images/amivWheel.svg',
prefix: 'favicon/',
prefix: 'assets/icons-[hash]/',
title: 'AMIV an der ETH',
favicons: {
appName: 'AMIV an der ETH',
......@@ -192,7 +203,6 @@ const config = {
title: 'AMIV an der ETH',
filename: 'index.html',
template: 'index.html',
hash: true,
}),
new HtmlWebpackInlineSVGPlugin(),
],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment