31 lines
822 B
JavaScript
31 lines
822 B
JavaScript
/** @type {import('next').NextConfig} */
|
|
const withPWA = require('next-pwa')({
|
|
dest: 'public',
|
|
})
|
|
|
|
const webpack = require('webpack');
|
|
|
|
let envMap;
|
|
try {
|
|
// .env-list.json provides us a list of identifiers which should be replaced at runtime.
|
|
envMap = require('./.env-list.json').reduce((a, v) => {
|
|
a[v] = `"CERC_RUNTIME_ENV_${v.split(/\./).pop()}"`;
|
|
return a;
|
|
}, {});
|
|
} catch {
|
|
// If .env-list.json cannot be loaded, we are probably running in dev mode, so use process.env instead.
|
|
envMap = Object.keys(process.env).reduce((a, v) => {
|
|
if (v.startsWith('CERC_')) {
|
|
a[`process.env.${v}`] = JSON.stringify(process.env[v]);
|
|
}
|
|
return a;
|
|
}, {});
|
|
}
|
|
|
|
module.exports = withPWA({
|
|
webpack: (config) => {
|
|
config.plugins.push(new webpack.DefinePlugin(envMap));
|
|
return config;
|
|
}
|
|
});
|