1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/server/build/index.js

22 lines
515 B
JavaScript
Raw Normal View History

2016-10-17 01:54:36 +00:00
import webpack from './webpack'
2016-10-06 11:05:52 +00:00
export default async function build (dir) {
2016-10-17 01:54:36 +00:00
const compiler = await webpack(dir)
2016-10-09 09:25:38 +00:00
2016-10-17 01:54:36 +00:00
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
if (err) return reject(err)
2016-10-06 11:05:52 +00:00
2016-10-17 01:54:36 +00:00
const jsonStats = stats.toJson()
if (jsonStats.errors.length > 0) {
const error = new Error(jsonStats.errors[0])
error.errors = jsonStats.errors
error.warnings = jsonStats.warnings
return reject(error)
}
2016-10-06 11:05:52 +00:00
2016-10-17 01:54:36 +00:00
resolve()
})
})
2016-10-06 11:05:52 +00:00
}