ente/next.config.js

83 lines
2.7 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-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 {
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,
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(
withBundleAnalyzer({
compiler: {
emotion: {
importMap: {
'@mui/material': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: ['@mui/material', 'styled'],
},
},
'@mui/material/styles': {
styled: {
canonicalImport: ['@emotion/styled', 'default'],
styledBaseImport: [
'@mui/material/styles',
'styled',
],
},
},
},
},
},
transpilePackages: [
'@mui/material',
'@mui/system',
'@mui/icons-material',
],
env: {
SENTRY_RELEASE: GIT_SHA,
NEXT_PUBLIC_IS_TEST_APP: process.env.IS_TEST_RELEASE,
},
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,
...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,
}
);