提交 123b4663 编写于 作者: R Robert Sköld 提交者: Tim Neutkens

Moved nanoid use from next-server to next/build (#5441)

上级 dccbc1ea
......@@ -27,11 +27,7 @@ const defaultConfig: NextConfig = {
assetPrefix: '',
configOrigin: 'default',
useFileSystemPublicRoutes: true,
generateBuildId: () => {
// nanoid is a small url-safe uuid generator
const nanoid = require('nanoid')
return nanoid()
},
generateBuildId: () => null,
generateEtags: true,
pageExtensions: ['jsx', 'js']
}
......
......@@ -2,6 +2,7 @@ import { join } from 'path'
import promisify from '../lib/promisify'
import fs from 'fs'
import webpack from 'webpack'
import nanoid from 'nanoid'
import loadConfig from 'next-server/next-config'
import { PHASE_PRODUCTION_BUILD, BUILD_ID_FILE } from 'next-server/constants'
import getBaseWebpackConfig from './webpack'
......@@ -11,9 +12,14 @@ const writeFile = promisify(fs.writeFile)
export default async function build (dir, conf = null) {
const config = loadConfig(PHASE_PRODUCTION_BUILD, dir, conf)
const buildId = await config.generateBuildId() // defaults to a uuid
const distDir = join(dir, config.distDir)
let buildId = await config.generateBuildId() // defaults to a uuid
if (buildId == null) {
// nanoid is a small url-safe uuid generator
buildId = nanoid()
}
try {
await access(dir, (fs.constants || fs).W_OK)
} catch (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册