const ora = require('ora');
const chalk = require('chalk');
const webpack = require('webpack');

const webConfig = require('./webpack.web.conf');

const ROOT = process.cwd();

const spinner = ora('building for pages...');
spinner.start();
webpack(webConfig(ROOT), (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');

    console.log(chalk.cyan('  Build pages complete.\n'));
});