mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-06-30 22:46:39 -04:00
use next-compose-plugins for simpler config
This commit is contained in:
235
next.config.js
235
next.config.js
@ -4,12 +4,10 @@
|
||||
|
||||
const path = require("path");
|
||||
const { PHASE_DEVELOPMENT_SERVER } = require("next/constants");
|
||||
const withPlugins = require("next-compose-plugins");
|
||||
const config = require("./lib/config");
|
||||
const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
||||
enabled: process.env.ANALYZE === "true",
|
||||
});
|
||||
|
||||
module.exports = (phase) => {
|
||||
module.exports = (phase, { defaultConfig }) => {
|
||||
let BASE_URL = ""; // fallback to relative urls
|
||||
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
|
||||
// vercel production (set manually)
|
||||
@ -22,119 +20,126 @@ module.exports = (phase) => {
|
||||
BASE_URL = "http://localhost:3000";
|
||||
}
|
||||
|
||||
return withBundleAnalyzer({
|
||||
swcMinify: true,
|
||||
reactStrictMode: true,
|
||||
trailingSlash: true,
|
||||
productionBrowserSourceMaps: true,
|
||||
env: {
|
||||
BASE_URL,
|
||||
},
|
||||
images: {
|
||||
formats: ["image/webp"],
|
||||
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
|
||||
},
|
||||
experimental: {
|
||||
optimizeFonts: true,
|
||||
optimizeImages: true,
|
||||
},
|
||||
webpack: (config) => {
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/,
|
||||
issuer: { and: [/\.(js|ts)x?$/] },
|
||||
include: [path.resolve(__dirname, "components/icons")],
|
||||
use: [
|
||||
{
|
||||
loader: "@svgr/webpack",
|
||||
options: {
|
||||
icon: true,
|
||||
typescript: true,
|
||||
svgProps: {
|
||||
"aria-hidden": true,
|
||||
className: "icon",
|
||||
return withPlugins(
|
||||
[
|
||||
require("@next/bundle-analyzer")({
|
||||
enabled: process.env.ANALYZE === "true",
|
||||
}),
|
||||
],
|
||||
{
|
||||
swcMinify: true,
|
||||
reactStrictMode: true,
|
||||
trailingSlash: true,
|
||||
productionBrowserSourceMaps: true,
|
||||
env: {
|
||||
BASE_URL,
|
||||
},
|
||||
images: {
|
||||
formats: ["image/webp"],
|
||||
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
|
||||
},
|
||||
experimental: {
|
||||
optimizeFonts: true,
|
||||
optimizeImages: true,
|
||||
},
|
||||
webpack: (config) => {
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/,
|
||||
issuer: { and: [/\.(js|ts)x?$/] },
|
||||
include: [path.resolve(__dirname, "components/icons")],
|
||||
use: [
|
||||
{
|
||||
loader: "@svgr/webpack",
|
||||
options: {
|
||||
icon: true,
|
||||
typescript: true,
|
||||
svgProps: {
|
||||
"aria-hidden": true,
|
||||
className: "icon",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
],
|
||||
});
|
||||
|
||||
return config;
|
||||
},
|
||||
headers: async () => [
|
||||
{
|
||||
source: "/:path(.*)",
|
||||
headers: [
|
||||
{
|
||||
key: "Onion-Location",
|
||||
value: `http://${config.onionDomain}/:path*`,
|
||||
},
|
||||
{
|
||||
// https://developer.chrome.com/blog/floc/#how-can-websites-opt-out-of-the-floc-computation
|
||||
key: "Permissions-Policy",
|
||||
value: "interest-cohort=()",
|
||||
},
|
||||
{
|
||||
key: "Referrer-Policy",
|
||||
value: "no-referrer-when-downgrade",
|
||||
},
|
||||
],
|
||||
return config;
|
||||
},
|
||||
{
|
||||
source: "/pubkey.asc",
|
||||
headers: [
|
||||
{
|
||||
key: "Cache-Control",
|
||||
value: "private, no-cache, no-store, must-revalidate",
|
||||
},
|
||||
{
|
||||
key: "Content-Type",
|
||||
value: "text/plain; charset=utf-8",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rewrites: async () => [
|
||||
{ source: "/favicon.ico", destination: "/static/favicons/favicon.ico" },
|
||||
{ source: "/apple-touch-icon.png", destination: "/static/favicons/apple-touch-icon.png" },
|
||||
{ source: "/apple-touch-icon-precomposed.png", destination: "/static/favicons/apple-touch-icon.png" },
|
||||
{ source: "/dark-mode-example/:path*", destination: "https://jakejarvis.github.io/dark-mode-example/:path*" },
|
||||
],
|
||||
redirects: async () => [
|
||||
{ source: "/notes/:slug/amp.html", destination: "/notes/:slug/", statusCode: 301 },
|
||||
{ source: "/resume/", destination: "/static/resume.pdf", permanent: false },
|
||||
{ source: "/stats/", destination: "https://app.usefathom.com/share/wbgnqukw/jarv.is", permanent: false },
|
||||
{ source: "/scrabble/:path*", destination: "https://jakejarvis.github.io/scrabble/:path*", permanent: false },
|
||||
{ source: "/jarvis.asc", destination: "/pubkey.asc", permanent: true },
|
||||
{ source: "/index.xml", destination: "/feed.xml", permanent: true },
|
||||
{ source: "/feed/", destination: "/feed.xml", permanent: true },
|
||||
{ source: "/rss/", destination: "/feed.xml", permanent: true },
|
||||
{ source: "/blog/:path*", destination: "/notes/", permanent: true },
|
||||
{ source: "/archives/:path*", destination: "/notes/", permanent: true },
|
||||
{
|
||||
source: "/2013/11/21/no-homo-still-raps-motto/",
|
||||
destination: "/notes/no-homo-still-raps-motto/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2016/02/28/millenial-with-hillary-clinton/",
|
||||
destination: "/notes/millenial-with-hillary-clinton/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2018/12/04/how-to-shrink-linux-virtual-disk-vmware/",
|
||||
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2018/12/07/shrinking-a-linux-virtual-disk-with-vmware/",
|
||||
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2018/12/10/cool-bash-tricks-for-your-terminal-dotfiles/",
|
||||
destination: "/notes/cool-bash-tricks-for-your-terminal-dotfiles/",
|
||||
permanent: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
headers: async () => [
|
||||
{
|
||||
source: "/:path(.*)",
|
||||
headers: [
|
||||
{
|
||||
key: "Onion-Location",
|
||||
value: `http://${config.onionDomain}/:path*`,
|
||||
},
|
||||
{
|
||||
// https://developer.chrome.com/blog/floc/#how-can-websites-opt-out-of-the-floc-computation
|
||||
key: "Permissions-Policy",
|
||||
value: "interest-cohort=()",
|
||||
},
|
||||
{
|
||||
key: "Referrer-Policy",
|
||||
value: "no-referrer-when-downgrade",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
source: "/pubkey.asc",
|
||||
headers: [
|
||||
{
|
||||
key: "Cache-Control",
|
||||
value: "private, no-cache, no-store, must-revalidate",
|
||||
},
|
||||
{
|
||||
key: "Content-Type",
|
||||
value: "text/plain; charset=utf-8",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
rewrites: async () => [
|
||||
{ source: "/favicon.ico", destination: "/static/favicons/favicon.ico" },
|
||||
{ source: "/apple-touch-icon.png", destination: "/static/favicons/apple-touch-icon.png" },
|
||||
{ source: "/apple-touch-icon-precomposed.png", destination: "/static/favicons/apple-touch-icon.png" },
|
||||
{ source: "/dark-mode-example/:path*", destination: "https://jakejarvis.github.io/dark-mode-example/:path*" },
|
||||
],
|
||||
redirects: async () => [
|
||||
{ source: "/notes/:slug/amp.html", destination: "/notes/:slug/", statusCode: 301 },
|
||||
{ source: "/resume/", destination: "/static/resume.pdf", permanent: false },
|
||||
{ source: "/stats/", destination: "https://app.usefathom.com/share/wbgnqukw/jarv.is", permanent: false },
|
||||
{ source: "/scrabble/:path*", destination: "https://jakejarvis.github.io/scrabble/:path*", permanent: false },
|
||||
{ source: "/jarvis.asc", destination: "/pubkey.asc", permanent: true },
|
||||
{ source: "/index.xml", destination: "/feed.xml", permanent: true },
|
||||
{ source: "/feed/", destination: "/feed.xml", permanent: true },
|
||||
{ source: "/rss/", destination: "/feed.xml", permanent: true },
|
||||
{ source: "/blog/:path*", destination: "/notes/", permanent: true },
|
||||
{ source: "/archives/:path*", destination: "/notes/", permanent: true },
|
||||
{
|
||||
source: "/2013/11/21/no-homo-still-raps-motto/",
|
||||
destination: "/notes/no-homo-still-raps-motto/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2016/02/28/millenial-with-hillary-clinton/",
|
||||
destination: "/notes/millenial-with-hillary-clinton/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2018/12/04/how-to-shrink-linux-virtual-disk-vmware/",
|
||||
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2018/12/07/shrinking-a-linux-virtual-disk-with-vmware/",
|
||||
destination: "/notes/how-to-shrink-linux-virtual-disk-vmware/",
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/2018/12/10/cool-bash-tricks-for-your-terminal-dotfiles/",
|
||||
destination: "/notes/cool-bash-tricks-for-your-terminal-dotfiles/",
|
||||
permanent: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
)(phase, { defaultConfig });
|
||||
};
|
||||
|
@ -45,6 +45,7 @@
|
||||
"markdown-to-jsx": "^7.1.5",
|
||||
"modern-normalize": "github:sindresorhus/modern-normalize#1fc6b5a86676b7ac8abc62d04d6080f92debc70f",
|
||||
"next": "v12.0.8-canary.17",
|
||||
"next-compose-plugins": "^2.2.1",
|
||||
"next-mdx-remote": "^3.0.8",
|
||||
"next-seo": "^4.28.1",
|
||||
"node-fetch": "^3.1.0",
|
||||
@ -68,7 +69,7 @@
|
||||
"devDependencies": {
|
||||
"@jakejarvis/eslint-config": "github:jakejarvis/eslint-config#main",
|
||||
"@svgr/webpack": "^6.1.2",
|
||||
"@types/lodash.groupby": "^4.6.6",
|
||||
"@types/prop-types": "^15.7.4",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/react-is": "^17.0.3",
|
||||
|
19
yarn.lock
19
yarn.lock
@ -1490,18 +1490,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
||||
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
|
||||
|
||||
"@types/lodash.groupby@^4.6.6":
|
||||
version "4.6.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash.groupby/-/lodash.groupby-4.6.6.tgz#4d9b61a4d8b0d83d384975cabfed4c1769d6792e"
|
||||
integrity sha512-kwg3T7Ia63KtDNoQQR8hKrLHCAgrH4I44l5uEMuA6JCbj7DiSccaV4tNV1vbjtAOpX990SolVthJCmBVtRVRgw==
|
||||
dependencies:
|
||||
"@types/lodash" "*"
|
||||
|
||||
"@types/lodash@*":
|
||||
version "4.14.178"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.178.tgz#341f6d2247db528d4a13ddbb374bcdc80406f4f8"
|
||||
integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==
|
||||
|
||||
"@types/mdast@^3.0.0":
|
||||
version "3.0.10"
|
||||
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.10.tgz#4724244a82a4598884cbbe9bcfd73dff927ee8af"
|
||||
@ -1534,7 +1522,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109"
|
||||
integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw==
|
||||
|
||||
"@types/prop-types@*":
|
||||
"@types/prop-types@*", "@types/prop-types@^15.7.4":
|
||||
version "15.7.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
|
||||
integrity sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==
|
||||
@ -4034,6 +4022,11 @@ natural-compare@^1.4.0:
|
||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
|
||||
|
||||
next-compose-plugins@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/next-compose-plugins/-/next-compose-plugins-2.2.1.tgz#020fc53f275a7e719d62521bef4300fbb6fde5ab"
|
||||
integrity sha512-OjJ+fV15FXO2uQXQagLD4C0abYErBjyjE0I0FHpOEIB8upw0hg1ldFP6cqHTJBH1cZqy96OeR3u1dJ+Ez2D4Bg==
|
||||
|
||||
next-mdx-remote@^3.0.8:
|
||||
version "3.0.8"
|
||||
resolved "https://registry.yarnpkg.com/next-mdx-remote/-/next-mdx-remote-3.0.8.tgz#ea2e7f9f3c99a0ce8167976c547e621d5930e1e0"
|
||||
|
Reference in New Issue
Block a user