Skip to content

Commit

Permalink
feat: migrate to preact (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
cubedhuang authored Jul 9, 2022
1 parent 6fb8254 commit d1d14ad
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 124 deletions.
22 changes: 14 additions & 8 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const withPreact = require("next-plugin-preact");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true"
});

module.exports = withBundleAnalyzer({
reactStrictMode: true,
swcMinify: true,
i18n: { locales: ["en-US"], defaultLocale: "en-US" },
images: {
domains: ["cdn.discordapp.com", "i.scdn.co", "skillicons.dev"]
}
});
module.exports = withBundleAnalyzer(
withPreact({
reactStrictMode: true,
swcMinify: true,
i18n: { locales: ["en-US"], defaultLocale: "en-US" },
images: {
domains: ["cdn.discordapp.com", "i.scdn.co", "skillicons.dev"]
},
experimental: {
esmExternals: false
}
})
);
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
"@next/bundle-analyzer": "^12.2.1",
"date-fns": "^2.28.0",
"date-fns-tz": "^1.3.5",
"next": "^12.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"next": "^12.2.2",
"next-plugin-preact": "^3.0.7",
"preact": "^10.9.0",
"preact-render-to-string": "^5.2.0",
"react": "npm:@preact/compat",
"react-dom": "npm:@preact/compat",
"react-ssr-prepass": "npm:preact-ssr-prepass",
"react-use-lanyard": "^0.1.2",
"spotify-web-api-node": "^5.0.2",
"swr": "^1.3.0"
Expand Down
4 changes: 2 additions & 2 deletions src/components/ActiveLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link, { LinkProps } from "next/link";
import { useRouter } from "next/router";
import React from "react";
import { cloneElement } from "preact";

export interface ActiveLinkProps extends LinkProps {
children: React.ReactElement;
Expand All @@ -19,7 +19,7 @@ export default function ActiveLink({

return (
<Link href={href} {...props}>
{React.cloneElement(children, {
{cloneElement(children, {
className:
router.pathname === href
? children.props.className
Expand Down
2 changes: 1 addition & 1 deletion src/components/Clock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import formatInTimeZone from "date-fns-tz/formatInTimeZone";
import { useEffect, useState } from "react";
import { useEffect, useState } from "preact/hooks";

export function Clock() {
const [now, setNow] = useState(0);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Spotify.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PauseIcon, PlayIcon } from "@heroicons/react/solid";
import Image from "next/image";
import { useEffect, useState } from "react";
import { useEffect, useState } from "preact/hooks";
import useSWR from "swr";

import type {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/music.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MusicNoteIcon } from "@heroicons/react/solid";
import { useEffect, useState } from "react";
import { useEffect, useState } from "preact/hooks";

import GenericMeta from "../components/GenericMeta";
import { TrackList } from "../components/TrackList";
Expand Down
268 changes: 160 additions & 108 deletions yarn.lock

Large diffs are not rendered by default.

1 comment on commit d1d14ad

@vercel
Copy link

@vercel vercel bot commented on d1d14ad Jul 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

danonl – ./

danonl-cubed.vercel.app
dannext.vercel.app
dan.onl
www.dan.onl
danonl-git-main-cubed.vercel.app

Please sign in to comment.