Skip to content

Commit

Permalink
Allow BUILD_ID to be set in the environment
Browse files Browse the repository at this point in the history
This makes multi server deploys with Capistrano possible.
  • Loading branch information
Craig McNamara authored and Matt Bessey committed Mar 2, 2018
1 parent 656434d commit 15e21b4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions server/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import fs from 'mz/fs'
import uuid from 'uuid'
import webpack from 'webpack'
import getConfig from '../config'
import {PHASE_PRODUCTION_BUILD} from '../../lib/constants'
import { PHASE_PRODUCTION_BUILD } from '../../lib/constants'
import getBaseWebpackConfig from './webpack'
import md5File from 'md5-file/promise'

export default async function build (dir, conf = null) {
export default async function build(dir, conf = null) {
const config = getConfig(PHASE_PRODUCTION_BUILD, dir, conf)
const buildId = uuid.v4()
const buildId = process.env.BUILD_ID || uuid.v4()

try {
await fs.access(dir, fs.constants.W_OK)
Expand All @@ -34,7 +34,7 @@ export default async function build (dir, conf = null) {
}
}

function runCompiler (compiler) {
function runCompiler(compiler) {
return new Promise(async (resolve, reject) => {
const webpackCompiler = await webpack(await compiler)
webpackCompiler.run((err, stats) => {
Expand All @@ -54,7 +54,7 @@ function runCompiler (compiler) {
})
}

async function writeBuildStats (dir, config) {
async function writeBuildStats(dir, config) {
// Here we can't use hashes in webpack chunks.
// That's because the "app.js" is not tied to a chunk.
// It's created by merging a few assets. (commons.js and main.js)
Expand All @@ -68,7 +68,7 @@ async function writeBuildStats (dir, config) {
await fs.writeFile(buildStatsPath, JSON.stringify(assetHashMap), 'utf8')
}

async function writeBuildId (dir, buildId, config) {
async function writeBuildId(dir, buildId, config) {
const buildIdPath = join(dir, config.distDir, 'BUILD_ID')
await fs.writeFile(buildIdPath, buildId, 'utf8')
}

0 comments on commit 15e21b4

Please sign in to comment.