From 7d5ede76f1aa20280c8b2a8b853f9329a4064f17 Mon Sep 17 00:00:00 2001 From: gibkigonzo Date: Sun, 14 Jun 2020 10:44:53 +0200 Subject: [PATCH] add purge-config loader --- config/default.json | 13 ++++++++++++- core/build/purge-config.js | 16 ++++++++++++++++ core/build/webpack.base.config.ts | 4 ++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 core/build/purge-config.js diff --git a/config/default.json b/config/default.json index 73bd7cc222..928c112767 100644 --- a/config/default.json +++ b/config/default.json @@ -871,5 +871,16 @@ }, "varnish": { "enabled":false - } + }, + "purgeConfig": [ + "server.invalidateCacheKey", + "server.invalidateCacheForwardUrl", + "server.trace", + "redis", + "install", + "expireHeaders", + "fastly", + "nginx", + "varnish" + ] } diff --git a/core/build/purge-config.js b/core/build/purge-config.js new file mode 100644 index 0000000000..f71fa891e0 --- /dev/null +++ b/core/build/purge-config.js @@ -0,0 +1,16 @@ +const omit = require('lodash/omit') + +/** + * clear config properties that shouldn't be visible on frontend + */ +module.exports = function loader(source) { + let config = JSON.parse(source); + + const purgeConfig = (config.purgeConfig || []).slice() + + config = omit(config, purgeConfig) + + delete config['purgeConfig'] + + return JSON.stringify(config); +} diff --git a/core/build/webpack.base.config.ts b/core/build/webpack.base.config.ts index a5002d33ca..2a87aa6f24 100644 --- a/core/build/webpack.base.config.ts +++ b/core/build/webpack.base.config.ts @@ -193,6 +193,10 @@ export default { test: /\.(graphqls|gql)$/, exclude: /node_modules/, loader: ['graphql-tag/loader'] + }, + { + test: /core\/build\/config\.json$/, + loader: path.resolve('core/build/purge-config.js') } ] }