mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-21 05:41:17 -04:00
attempt to make edge functions a tad bit lighter
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { serialize } from "next-mdx-remote/serialize";
|
||||
import { minify } from "uglify-js";
|
||||
import { getNoteData } from "./parse-notes";
|
||||
import { IS_DEV_SERVER } from "../config/constants";
|
||||
|
||||
// remark/rehype markdown plugins
|
||||
import remarkGfm from "remark-gfm";
|
||||
@@ -38,14 +37,15 @@ export const compileNote = async (slug: string): Promise<NoteWithSource> => {
|
||||
// TODO: next-mdx-remote v4 doesn't (yet?) minify compiled JSX output, see:
|
||||
// https://github.com/hashicorp/next-mdx-remote/pull/211#issuecomment-1013658514
|
||||
// ...so for now, let's do it manually (and conservatively) with uglify-js when building for production.
|
||||
const compiledSource = IS_DEV_SERVER
|
||||
? source.compiledSource
|
||||
: minify(source.compiledSource, {
|
||||
toplevel: true,
|
||||
parse: {
|
||||
bare_returns: true,
|
||||
},
|
||||
}).code;
|
||||
const compiledSource =
|
||||
process.env.NODE_ENV === "production"
|
||||
? minify(source.compiledSource, {
|
||||
toplevel: true,
|
||||
parse: {
|
||||
bare_returns: true,
|
||||
},
|
||||
}).code
|
||||
: source.compiledSource;
|
||||
|
||||
return {
|
||||
frontMatter,
|
||||
|
Reference in New Issue
Block a user