yandere_fe/build/build.js
Xnuk Shuman 6d6629eb50
Throw non-zero exit code if webpack build fails
Not only `err`, `stats.hasErrors` also should be handled.
I found this bug in [Pipeline 42881 build] - some errors exist,
but build result was successful.

See also: https://webpack.js.org/api/node/#error-handling

[Pipeline 42881 build]: https://git.pleroma.social/pleroma/pleroma-fe/-/jobs/225066
2022-12-10 14:55:04 +09:00

44 lines
1.1 KiB
JavaScript

// https://github.com/shelljs/shelljs
require('./check-versions')()
require('shelljs/global')
env.NODE_ENV = 'production'
var path = require('path')
var config = require('../config')
var ora = require('ora')
var webpack = require('webpack')
var webpackConfig = require('./webpack.prod.conf')
console.log(
' Tip:\n' +
' Built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
)
var spinner = ora('building for production...')
spinner.start()
var updateEmoji = require('./update-emoji').updateEmoji
updateEmoji()
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
rm('-rf', assetsPath)
mkdir('-p', assetsPath)
cp('-R', 'static/*', assetsPath)
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n')
if (stats.hasErrors()) {
console.error('See above for errors.')
process.exit(1)
}
})