ente/next.config.js

70 lines
2.2 KiB
JavaScript
Raw Normal View History

2020-10-03 14:21:56 +00:00
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
2021-06-15 19:07:01 +00:00
const withWorkbox = require('@ente-io/next-with-workbox');
2021-12-03 14:48:05 +00:00
const { withSentryConfig } = require('@sentry/nextjs');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
2021-03-08 11:59:14 +00:00
const withTM = require('next-transpile-modules')([
'@mui/material',
'@mui/system',
2022-04-23 17:11:27 +00:00
'@mui/icons-material',
]);
const {
getGitSha,
convertToNextHeaderFormat,
2022-04-27 08:20:17 +00:00
buildCSPHeader,
COOP_COEP_HEADERS,
WEB_SECURITY_HEADERS,
2022-04-27 08:20:17 +00:00
CSP_DIRECTIVES,
WORKBOX_CONFIG,
ALL_ROUTES,
getIsSentryEnabled,
} = require('./configUtil');
2022-01-07 11:58:05 +00:00
const GIT_SHA = getGitSha();
const IS_SENTRY_ENABLED = getIsSentryEnabled();
2022-01-07 05:59:01 +00:00
module.exports = (phase) =>
withSentryConfig(
withWorkbox(
withBundleAnalyzer(
withTM({
env: {
SENTRY_RELEASE: GIT_SHA,
NEXT_PUBLIC_LATEST_COMMIT_HASH: GIT_SHA,
},
workbox: WORKBOX_CONFIG,
2022-01-07 05:59:01 +00:00
headers() {
return [
{
// Apply these headers to all routes in your application....
source: ALL_ROUTES,
headers: convertToNextHeaderFormat({
...COOP_COEP_HEADERS,
...WEB_SECURITY_HEADERS,
2022-04-27 08:20:17 +00:00
...buildCSPHeader(CSP_DIRECTIVES),
}),
},
];
},
// https://dev.to/marcinwosinek/how-to-add-resolve-fallback-to-webpack-5-in-nextjs-10-i6j
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
}
return config;
},
})
2022-05-26 07:48:34 +00:00
)
),
{
release: GIT_SHA,
dryRun: phase === PHASE_DEVELOPMENT_SERVER || !IS_SENTRY_ENABLED,
}
);