1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

mascara - serve popup bundle

This commit is contained in:
kumavis 2016-09-13 10:19:40 -07:00
parent f7794d9949
commit 81d25d560f

View File

@ -2,11 +2,10 @@ const express = require('express')
const browserify = require('browserify') const browserify = require('browserify')
const watchify = require('watchify') const watchify = require('watchify')
const babelify = require('babelify') const babelify = require('babelify')
const path = require('path')
const zeroBundle = createBundle('./index.js') const zeroBundle = createBundle('./index.js')
const controllerBundle = createBundle('./controller.js') const controllerBundle = createBundle('./controller.js')
// const popupBundle = createBundle('./popup.js') const popupBundle = createBundle('./popup.js')
const appBundle = createBundle('./example/index.js') const appBundle = createBundle('./example/index.js')
// //
@ -16,9 +15,9 @@ const appBundle = createBundle('./example/index.js')
const iframeServer = express() const iframeServer = express()
// serve popup window // serve popup window
// iframeServer.get('/popup/scripts/popup.js', function(req, res){ iframeServer.get('/popup/scripts/popup.js', function(req, res){
// res.send(popupBundle.latest) res.send(popupBundle.latest)
// }) })
iframeServer.use('/popup', express.static('../dist/chrome')) iframeServer.use('/popup', express.static('../dist/chrome'))
// serve controller bundle // serve controller bundle
@ -29,8 +28,10 @@ iframeServer.get('/controller.js', function(req, res){
// serve background controller // serve background controller
iframeServer.use(express.static('./server')) iframeServer.use(express.static('./server'))
// start the server
iframeServer.listen('9001') const mascaraPort = 9001
iframeServer.listen(mascaraPort)
console.log(`Mascara service listening on port ${mascaraPort}`)
// //
@ -39,7 +40,6 @@ iframeServer.listen('9001')
const dappServer = express() const dappServer = express()
// serve metamask-lib bundle // serve metamask-lib bundle
dappServer.get('/zero.js', function(req, res){ dappServer.get('/zero.js', function(req, res){
res.send(zeroBundle.latest) res.send(zeroBundle.latest)
@ -53,10 +53,22 @@ dappServer.get('/app.js', function(req, res){
// serve static // serve static
dappServer.use(express.static('./example')) dappServer.use(express.static('./example'))
// start the server
const dappPort = '9002' const dappPort = '9002'
dappServer.listen(dappPort) dappServer.listen(dappPort)
console.log(`Dapp listening on port ${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){ function createBundle(entryPoint){
var bundleContainer = {} var bundleContainer = {}
@ -69,14 +81,14 @@ function createBundle(entryPoint){
}) })
// global transpile // global transpile
var bablePreset = path.resolve(__dirname, '../node_modules/babel-preset-es2015') var bablePreset = require.resolve('babel-preset-es2015')
bundler.transform(babelify, { bundler.transform(babelify, {
global: true, global: true,
presets: [bablePreset], presets: [bablePreset],
babelrc: false,
}) })
bundler.on('update', bundle) bundler.on('update', bundle)
bundle() bundle()