diff options
Diffstat (limited to 'mascara/server/util.js')
-rw-r--r-- | mascara/server/util.js | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/mascara/server/util.js b/mascara/server/util.js deleted file mode 100644 index f9692afb6..000000000 --- a/mascara/server/util.js +++ /dev/null @@ -1,47 +0,0 @@ -const browserify = require('browserify') -const watchify = require('watchify') - -module.exports = { - serveBundle, - createBundle, -} - - -function serveBundle (server, path, bundle) { - server.get(path, function (req, res) { - res.setHeader('Content-Type', 'application/javascript; charset=UTF-8') - res.send(bundle.latest) - }) -} - -function createBundle (entryPoint) { - - var bundleContainer = {} - - var bundler = browserify({ - entries: [entryPoint], - cache: {}, - packageCache: {}, - plugin: [watchify], - }) - .transform('babelify') - .transform('uglifyify', { global: true }) - - bundler.on('update', bundle) - bundle() - - return bundleContainer - - function bundle () { - bundler.bundle(function (err, result) { - if (err) { - console.log(`Bundle failed! (${entryPoint})`) - console.error(err) - return - } - console.log(`Bundle updated! (${entryPoint})`) - bundleContainer.latest = result.toString() - }) - } - -} |