You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
854 B
JavaScript
30 lines
854 B
JavaScript
5 years ago
|
/* eslint-disable */
|
||
|
import fs from 'fs';
|
||
|
import webpack from 'webpack';
|
||
|
import root from './utils/root';
|
||
|
import webpackConfig from './config/webpack';
|
||
|
|
||
|
export default function ({ watch, production }) {
|
||
|
const compiler = webpack(webpackConfig({ watch, production }));
|
||
|
compiler.apply(new webpack.ProgressPlugin());
|
||
|
|
||
|
const outputOptions = {
|
||
|
colors: true,
|
||
|
errorDetails: true,
|
||
|
optimizationBailout: production,
|
||
|
};
|
||
|
|
||
|
function compilerCallback(err, stats) {
|
||
|
if (err) {
|
||
|
console.error(err.stack || err);
|
||
|
if (err.details) console.error(err.details);
|
||
|
process.exit(1);
|
||
|
}
|
||
|
fs.writeFileSync(root('./.webpackStats.json'), JSON.stringify(stats.toJson(), null, 2));
|
||
|
if (!watch && stats.hasErrors()) process.exitCode = 1;
|
||
|
}
|
||
|
|
||
|
if (watch) compiler.watch({}, compilerCallback);
|
||
|
else compiler.run(compilerCallback);
|
||
|
}
|