start.js 714 Bytes
'use strict';

process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';

process.on('unhandledRejection', (err) => { throw err; });

const fs = require('fs-extra');
const webpack = require('webpack');
const nodemon = require('nodemon');
const config = require('../config/webpack.config.dev');
const paths = require('../config/paths');

const compiler = webpack(config);

fs.emptyDirSync(paths.temporalOutput);

const run = () => new Promise((res, rej) => {
  compiler.watch({}, (err, stats) => {
    if (err)
      rej(err)
    else
      res(stats);
  });
})

async function go() {
  await run();
  nodemon({ 
    script: `${paths.temporalOutput}/index.js`, 
    ext: 'js json'
   });
}

go();