1 | const emoji = require('node-emoji')
|
2 | const EventEmitter = require('events')
|
3 | const chalk = require('chalk')
|
4 |
|
5 | const getWebpackConfig = require('../utils/getWebpackConfig')
|
6 | const createWebpackCompiler = require('../utils/createWebpackCompiler')
|
7 | const cleanWebpackOutputDir = require('../utils/cleanWebpackOutputDir')
|
8 |
|
9 | const { PROFILE } = process.env
|
10 |
|
11 | module.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 | }
|