Add allowing push notifications

This commit is contained in:
pikiou
2022-01-11 13:54:34 +01:00
parent db6d296f05
commit c7941aefc3
16 changed files with 479 additions and 66 deletions

View File

@@ -125,4 +125,28 @@ const config = (isWeb = false): Configuration => ({
},
})
export function getClientEnvironment(allowedKeys: string[]): any {
const raw = Object.keys(process.env)
// Custom regex to allow only a certain category of variables available to the application
.filter((key) => allowedKeys.indexOf(key) >= 0)
.reduce(
(env: any, key: string) => {
env[key] = process.env[key]
return env
},
{
NODE_ENV: process.env.NODE_ENV || "development",
}
)
// Stringify all values so we can feed into Webpack DefinePlugin
const stringified = {
"process.env": Object.keys(raw).reduce((env: any, key: string) => {
env[key] = JSON.stringify(raw[key])
return env
}, {}),
}
return stringified
}
export default config

View File

@@ -7,7 +7,7 @@ import CompressionPlugin from "compression-webpack-plugin"
import ImageMinimizerPlugin from "image-minimizer-webpack-plugin"
import merge from "webpack-merge"
import baseConfig, { isDev } from "./base.config"
import baseConfig, { isDev, getClientEnvironment } from "./base.config"
const getPlugins = () => {
let plugins = [
@@ -16,6 +16,7 @@ const getPlugins = () => {
filename: isDev ? "[name].css" : "[name].[contenthash].css",
chunkFilename: isDev ? "[id].css" : "[id].[contenthash].css",
}),
new webpack.DefinePlugin(getClientEnvironment(["FORCE_ORANGE_PUBLIC_VAPID_KEY"])),
]
if (isDev)