UNPKG

915 BJavaScriptView Raw
1const emoji = require('node-emoji')
2const EventEmitter = require('events')
3const chalk = require('chalk')
4
5const getWebpackConfig = require('../utils/getWebpackConfig')
6const createWebpackCompiler = require('../utils/createWebpackCompiler')
7const cleanWebpackOutputDir = require('../utils/cleanWebpackOutputDir')
8
9const { PROFILE } = process.env
10
11module.exports = options => {
12 const start = new Date()
13
14 process.env.GNOLL_ENTRY = options.entry
15 process.env.GNOLL_TARGET = options.target
16 process.env.GNOLL_ENV = options.env
17 if (options.caching) process.env.GNOLL_ASSETS_CACHING = 1
18
19 const emitter = new EventEmitter()
20 const config = getWebpackConfig(options)
21
22 cleanWebpackOutputDir(config)
23
24 const compiler = createWebpackCompiler(config, options)
25 console.log(
26 emoji.get('eyes'),
27 chalk.bold(' Creating development build and rebuilding on changes...\n')
28 )
29 compiler.watch({}, () => {})
30
31 return emitter
32}