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