2020-08-13 10:39:46 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const ora = require('ora');
|
|
|
|
const rm = require('rimraf');
|
|
|
|
const chalk = require('chalk');
|
2021-03-11 07:18:13 +00:00
|
|
|
const config = require('./webpack.config.js');
|
2020-08-13 10:39:46 +00:00
|
|
|
|
|
|
|
const env = process.env.NODE_ENV || 'development';
|
|
|
|
const target = process.env.TARGET || 'web';
|
|
|
|
|
|
|
|
const spinner = ora(env === 'production' ? 'building for production...' : 'building development version...');
|
|
|
|
spinner.start();
|
|
|
|
|
2020-11-25 20:16:45 +00:00
|
|
|
rm('./www/', (removeErr) => {
|
2020-08-13 10:39:46 +00:00
|
|
|
if (removeErr) throw removeErr;
|
|
|
|
|
|
|
|
webpack(config, (err, stats) => {
|
|
|
|
if (err) throw err;
|
|
|
|
spinner.stop();
|
|
|
|
|
|
|
|
process.stdout.write(`${stats.toString({
|
|
|
|
colors: true,
|
|
|
|
modules: false,
|
|
|
|
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
|
|
|
|
chunks: false,
|
|
|
|
chunkModules: false,
|
|
|
|
})}\n\n`);
|
|
|
|
|
|
|
|
if (stats.hasErrors()) {
|
|
|
|
console.log(chalk.red('Build failed with errors.\n'));
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(chalk.cyan('Build complete.\n'));
|
|
|
|
});
|
|
|
|
});
|