aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-09-14 01:19:40 +0800
committerkumavis <aaron@kumavis.me>2016-09-14 01:19:40 +0800
commit81d25d560f4920ee7a357881931e674bea97176c (patch)
treea2b85fba2f42921ce2c9afb158f6bcad787f4ea0 /library
parentf7794d9949a0470ccb6c872925ca0b575806b507 (diff)
downloadtangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.tar
tangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.tar.gz
tangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.tar.bz2
tangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.tar.lz
tangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.tar.xz
tangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.tar.zst
tangerine-wallet-browser-81d25d560f4920ee7a357881931e674bea97176c.zip
mascara - serve popup bundle
Diffstat (limited to 'library')
-rw-r--r--library/server.js32
1 files changed, 22 insertions, 10 deletions
diff --git a/library/server.js b/library/server.js
index 033c65358..bb0b24e50 100644
--- a/library/server.js
+++ b/library/server.js
@@ -2,11 +2,10 @@ const express = require('express')
const browserify = require('browserify')
const watchify = require('watchify')
const babelify = require('babelify')
-const path = require('path')
const zeroBundle = createBundle('./index.js')
const controllerBundle = createBundle('./controller.js')
-// const popupBundle = createBundle('./popup.js')
+const popupBundle = createBundle('./popup.js')
const appBundle = createBundle('./example/index.js')
//
@@ -16,9 +15,9 @@ const appBundle = createBundle('./example/index.js')
const iframeServer = express()
// serve popup window
-// iframeServer.get('/popup/scripts/popup.js', function(req, res){
-// res.send(popupBundle.latest)
-// })
+iframeServer.get('/popup/scripts/popup.js', function(req, res){
+ res.send(popupBundle.latest)
+})
iframeServer.use('/popup', express.static('../dist/chrome'))
// serve controller bundle
@@ -29,8 +28,10 @@ iframeServer.get('/controller.js', function(req, res){
// serve background controller
iframeServer.use(express.static('./server'))
-
-iframeServer.listen('9001')
+// start the server
+const mascaraPort = 9001
+iframeServer.listen(mascaraPort)
+console.log(`Mascara service listening on port ${mascaraPort}`)
//
@@ -39,7 +40,6 @@ iframeServer.listen('9001')
const dappServer = express()
-
// serve metamask-lib bundle
dappServer.get('/zero.js', function(req, res){
res.send(zeroBundle.latest)
@@ -53,10 +53,22 @@ dappServer.get('/app.js', function(req, res){
// serve static
dappServer.use(express.static('./example'))
+// start the server
const dappPort = '9002'
dappServer.listen(dappPort)
console.log(`Dapp listening on port ${dappPort}`)
+//
+// util
+//
+
+function serveBundle(entryPoint){
+ const bundle = createBundle(entryPoint)
+ return function(req, res){
+ res.send(bundle.latest)
+ }
+}
+
function createBundle(entryPoint){
var bundleContainer = {}
@@ -69,14 +81,14 @@ function createBundle(entryPoint){
})
// global transpile
- var bablePreset = path.resolve(__dirname, '../node_modules/babel-preset-es2015')
+ var bablePreset = require.resolve('babel-preset-es2015')
bundler.transform(babelify, {
global: true,
presets: [bablePreset],
+ babelrc: false,
})
-
bundler.on('update', bundle)
bundle()