forked from Crossbell-Box/xLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
62 lines (55 loc) · 1.58 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// @ts-check
const pkg = require("./package.json")
const spawn = require("cross-spawn")
const { withIpfsGateway } = require("@crossbell/ipfs-gateway-next")
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
})
const execSync = require("child_process").execSync
const lastCommitCommand = "git rev-parse HEAD"
class UnoCSS {
/**
*
* @param {import('webpack').Compiler} compiler
*/
apply(compiler) {
compiler.hooks.beforeRun.tapPromise("unocss", async () => {
if (globalThis.uno_built) return
globalThis.uno_watching = true
spawn.sync("pnpm", ["uno-generate"], { stdio: "inherit" })
})
compiler.hooks.watchRun.tap("unocss", () => {
if (globalThis.uno_watching) return
globalThis.uno_watching = true
spawn("pnpm", ["uno-generate", "--watch"], { stdio: "inherit" })
})
}
}
/** @type {import('next').NextConfig} */
module.exports = withBundleAnalyzer(
withIpfsGateway({
env: {
APP_DESCRIPTION: pkg.description,
},
experimental: {
scrollRestoration: true,
},
output: "standalone",
webpack(config) {
config.plugins.push(new UnoCSS())
return config
},
ipfsGateway: {
gatewayPath: "/_ipfs/:cid/:pathToResource*",
},
images: {
dangerouslyAllowSVG: true,
contentSecurityPolicy:
"default-src 'self'; script-src 'none'; sandbox; style-src 'unsafe-inline';",
remotePatterns: [{ hostname: "**" }],
},
async generateBuildId() {
return execSync(lastCommitCommand).toString().trim()
},
}),
)