Skip to content

Commit

Permalink
Stage 2: Setup Velite
Browse files Browse the repository at this point in the history
  • Loading branch information
Jihillestad committed Jul 17, 2024
1 parent 620c7e9 commit b8bf6a8
Show file tree
Hide file tree
Showing 7 changed files with 5,054 additions and 2,210 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# velite files
.velite
10 changes: 10 additions & 0 deletions content/blog/hello-world.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Hello World
description: This is our first blog post
date: 2024-07-17
published: true
---

# Hello World

Welcome to my blog
24 changes: 22 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
import { build } from "velite";

/** @type {import('next').NextConfig} */
const nextConfig = {};
export default {
// othor next config here...
webpack: (config) => {
config.plugins.push(new VeliteWebpackPlugin());
return config;
},
};

export default nextConfig;
class VeliteWebpackPlugin {
static started = false;
apply(/** @type {import('webpack').Compiler} */ compiler) {
// executed three times in nextjs
// twice for the server (nodejs / edge runtime) and once for the client
compiler.hooks.beforeCompile.tapPromise("VeliteWebpackPlugin", async () => {
if (VeliteWebpackPlugin.started) return;
VeliteWebpackPlugin.started = true;
const dev = compiler.options.mode === "development";
await build({ watch: dev, clean: !dev });
});
}
}
Loading

0 comments on commit b8bf6a8

Please sign in to comment.