Skip to content

Commit

Permalink
add purge-config loader
Browse files Browse the repository at this point in the history
  • Loading branch information
gibkigonzo committed Jun 14, 2020
1 parent d04b90f commit 7d5ede7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
13 changes: 12 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -871,5 +871,16 @@
},
"varnish": {
"enabled":false
}
},
"purgeConfig": [
"server.invalidateCacheKey",
"server.invalidateCacheForwardUrl",
"server.trace",
"redis",
"install",
"expireHeaders",
"fastly",
"nginx",
"varnish"
]
}
16 changes: 16 additions & 0 deletions core/build/purge-config.js
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 4 additions & 0 deletions core/build/webpack.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
]
}
Expand Down

0 comments on commit 7d5ede7

Please sign in to comment.