-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.cjs
More file actions
33 lines (27 loc) · 875 Bytes
/
build.cjs
File metadata and controls
33 lines (27 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const path = require('path');
const ora = require('ora');
const rm = require('rimraf');
const chalk = require('chalk');
const webpack = require('webpack');
const webpackConfig = require('./webpack.prod.conf.cjs');
const spinner = ora('building for production... ');
spinner.start();
rm(path.resolve(__dirname, '../dist'), (e) => {
if (e) throw e;
webpack(webpackConfig, (err, stats) => {
spinner.stop();
if (err) throw err;
process.stdout.write(`${stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
})}\n\n`);
if (stats.hasErrors()) {
spinner.fail(chalk.red('Build failed with errors.\n'))
process.exit(1);
}
spinner.succeed(chalk.cyan('Build complete.\n'))
});
});