Skip to content

Commit 344471d

Browse files
committed
feat: velite plugins
1 parent 42a5650 commit 344471d

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

next.config.mjs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
import "./env.mjs"
2-
// import { build } from "velite"
2+
import { build } from "velite"
33

44
/** @type {import('next').NextConfig} */
55
const nextConfig = {
66
images: {
77
domains: ["avatars.githubusercontent.com"],
88
},
99
webpack: config => {
10-
// config.plugins.push(new VeliteWebpackPlugin())
10+
config.plugins.push(new VeliteWebpackPlugin())
1111
return config
1212
}
1313
}
1414

15-
// class VeliteWebpackPlugin {
16-
// static started = false
17-
// apply(/** @type {import('webpack').Compiler} */ compiler) {
18-
// // executed three times in nextjs
19-
// // twice for the server (nodejs / edge runtime) and once for the client
20-
// compiler.hooks.beforeCompile.tapPromise('VeliteWebpackPlugin', async () => {
21-
// if (VeliteWebpackPlugin.started) return
22-
// VeliteWebpackPlugin.started = true
23-
// const dev = compiler.options.mode === 'development'
24-
// await build({ watch: dev, clean: !dev })
25-
// })
26-
// }
27-
// }
15+
class VeliteWebpackPlugin {
16+
static started = false
17+
apply(compiler) {
18+
compiler.hooks.beforeCompile.tapPromise('VeliteWebpackPlugin', async () => {
19+
if (VeliteWebpackPlugin.started) return
20+
VeliteWebpackPlugin.started = true
21+
const dev = compiler.options.mode === 'development'
22+
await build({ watch: dev, clean: !dev })
23+
})
24+
}
25+
}
2826

2927
export default nextConfig

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"scripts": {
1010
"dev": "next dev",
11-
"build": "velite && next build",
11+
"build": "next build",
1212
"turbo": "next dev --turbo",
1313
"start": "next start",
1414
"lint": "next lint",

0 commit comments

Comments
 (0)