mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Moved nanoid use from next-server to next/build (#5441)
This commit is contained in:
parent
dccbc1ea35
commit
123b46634a
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue