2021-08-20 00:31:18 +00:00
|
|
|
/// <reference path='./next-pwa.d.ts' />
|
|
|
|
import type { BlitzConfig } from "blitz";
|
|
|
|
import { sessionMiddleware, simpleRolesIsAuthorized } from "blitz";
|
2021-09-06 20:49:13 +00:00
|
|
|
import SentryWebpackPlugin from "@sentry/webpack-plugin";
|
2021-08-20 00:31:18 +00:00
|
|
|
// import withPWA from "next-pwa";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
2021-08-20 00:31:18 +00:00
|
|
|
type Module = Omit<NodeModule, "exports"> & { exports: BlitzConfig };
|
2021-08-01 16:28:47 +00:00
|
|
|
|
2021-09-06 20:49:13 +00:00
|
|
|
const { SENTRY_DSN, SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN, NODE_ENV, GITHUB_SHA } = process.env;
|
|
|
|
|
2021-08-20 00:31:18 +00:00
|
|
|
(module as Module).exports = {
|
2021-08-25 08:52:24 +00:00
|
|
|
async header() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
source: "/fonts/*.woff2",
|
|
|
|
headers: [
|
|
|
|
{
|
|
|
|
key: "Cache-Control",
|
|
|
|
value: "public, max-age=31536000, immutable",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
2021-08-28 22:14:18 +00:00
|
|
|
async rewrites() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
source: "/bear.js",
|
|
|
|
destination: "https://cdn.panelbear.com/analytics.js",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
2021-07-31 14:33:18 +00:00
|
|
|
middleware: [
|
|
|
|
sessionMiddleware({
|
2021-08-03 13:03:10 +00:00
|
|
|
cookiePrefix: "shellphone",
|
2021-07-31 14:33:18 +00:00
|
|
|
isAuthorized: simpleRolesIsAuthorized,
|
|
|
|
}),
|
|
|
|
],
|
2021-08-27 16:08:38 +00:00
|
|
|
images: {
|
|
|
|
domains: ["www.datocms-assets.com"],
|
|
|
|
},
|
2021-09-06 20:49:13 +00:00
|
|
|
productionBrowserSourceMaps: true,
|
|
|
|
env: {
|
|
|
|
SENTRY_DSN: process.env.SENTRY_DSN,
|
|
|
|
},
|
2021-07-31 14:33:18 +00:00
|
|
|
serverRuntimeConfig: {
|
2021-09-06 20:49:13 +00:00
|
|
|
rootDir: __dirname,
|
|
|
|
masterEncryptionKey: process.env.MASTER_ENCRYPTION_KEY,
|
2021-07-31 14:33:18 +00:00
|
|
|
paddle: {
|
|
|
|
apiKey: process.env.PADDLE_API_KEY,
|
|
|
|
},
|
|
|
|
awsSes: {
|
|
|
|
awsRegion: process.env.AWS_SES_REGION,
|
|
|
|
accessKeyId: process.env.AWS_SES_ACCESS_KEY_ID,
|
|
|
|
secretAccessKey: process.env.AWS_SES_ACCESS_KEY_SECRET,
|
|
|
|
fromEmail: process.env.AWS_SES_FROM_EMAIL,
|
|
|
|
},
|
2021-09-15 22:56:16 +00:00
|
|
|
awsS3: {
|
|
|
|
awsRegion: process.env.AWS_S3_REGION,
|
|
|
|
accessKeyId: process.env.AWS_S3_ACCESS_KEY_ID,
|
|
|
|
secretAccessKey: process.env.AWS_S3_ACCESS_KEY_SECRET,
|
|
|
|
},
|
2021-07-31 14:33:18 +00:00
|
|
|
mailChimp: {
|
|
|
|
apiKey: process.env.MAILCHIMP_API_KEY,
|
|
|
|
audienceId: process.env.MAILCHIMP_AUDIENCE_ID,
|
|
|
|
},
|
2021-08-01 10:54:51 +00:00
|
|
|
app: {
|
2021-08-01 16:28:47 +00:00
|
|
|
baseUrl: process.env.APP_BASE_URL,
|
|
|
|
},
|
|
|
|
webPush: {
|
|
|
|
privateKey: process.env.WEB_PUSH_VAPID_PRIVATE_KEY,
|
|
|
|
},
|
2021-08-03 21:04:17 +00:00
|
|
|
datoCms: {
|
|
|
|
apiToken: process.env.DATOCMS_API_TOKEN,
|
|
|
|
previewSecret: process.env.DATOCMS_PREVIEW_SECRET,
|
|
|
|
},
|
2021-08-01 16:28:47 +00:00
|
|
|
},
|
|
|
|
publicRuntimeConfig: {
|
|
|
|
webPush: {
|
|
|
|
publicKey: process.env.WEB_PUSH_VAPID_PUBLIC_KEY,
|
2021-08-01 10:54:51 +00:00
|
|
|
},
|
2021-08-28 22:14:18 +00:00
|
|
|
panelBear: {
|
|
|
|
siteId: process.env.PANELBEAR_SITE_ID,
|
|
|
|
},
|
2021-09-26 22:44:26 +00:00
|
|
|
paddle: {
|
|
|
|
vendorId: process.env.PADDLE_VENDOR_ID,
|
|
|
|
},
|
2021-07-31 14:33:18 +00:00
|
|
|
},
|
2021-09-06 20:49:13 +00:00
|
|
|
// @ts-ignore
|
2021-07-31 14:33:18 +00:00
|
|
|
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
2021-09-06 20:49:13 +00:00
|
|
|
// In `pages/_app.js`, Sentry is imported from @sentry/browser. While
|
|
|
|
// @sentry/node will run in a Node.js environment. @sentry/node will use
|
|
|
|
// Node.js-only APIs to catch even more unhandled exceptions.
|
|
|
|
//
|
|
|
|
// This works well when Next.js is SSRing your page on a server with
|
|
|
|
// Node.js, but it is not what we want when your client-side bundle is being
|
|
|
|
// executed by a browser.
|
|
|
|
//
|
|
|
|
// Luckily, Next.js will call this webpack function twice, once for the
|
|
|
|
// server and once for the client. Read more:
|
|
|
|
// https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config
|
|
|
|
//
|
|
|
|
// So ask Webpack to replace @sentry/node imports with @sentry/browser when
|
|
|
|
// building the browser's bundle
|
|
|
|
if (!isServer) {
|
|
|
|
config.resolve.alias["@sentry/node"] = "@sentry/browser";
|
|
|
|
}
|
|
|
|
|
|
|
|
// When all the Sentry configuration env variables are available/configured
|
|
|
|
// The Sentry webpack plugin gets pushed to the webpack plugins to build
|
|
|
|
// and upload the source maps to sentry.
|
|
|
|
// This is an alternative to manually uploading the source maps
|
|
|
|
// Note: This is disabled in development mode.
|
|
|
|
if (
|
|
|
|
SENTRY_DSN &&
|
|
|
|
SENTRY_ORG &&
|
|
|
|
SENTRY_PROJECT &&
|
|
|
|
SENTRY_AUTH_TOKEN &&
|
|
|
|
GITHUB_SHA &&
|
|
|
|
NODE_ENV === "production"
|
|
|
|
) {
|
|
|
|
config.plugins.push(
|
|
|
|
new SentryWebpackPlugin({
|
|
|
|
include: ".next",
|
|
|
|
ignore: ["node_modules"],
|
|
|
|
stripPrefix: ["webpack://_N_E/"],
|
|
|
|
urlPrefix: `~/_next`,
|
|
|
|
release: GITHUB_SHA,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
2021-07-31 14:33:18 +00:00
|
|
|
},
|
2021-08-20 00:31:18 +00:00
|
|
|
/*pwa: {
|
|
|
|
dest: "public",
|
|
|
|
disable: process.env.NODE_ENV !== "production",
|
|
|
|
},*/
|
2021-07-31 15:57:43 +00:00
|
|
|
};
|