1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-24 09:12:20 +03:00
leon/scripts/app/build-app.js
ctombumila37 a438d6f942 fix(web app): enable environment variables
Enable environment variables by pulling in 'envify' as a dependency.
'envify' loads a file named '.env' lying in the leon root directory and
replaces any occurence of process.env.FOO by the corresponding entry in
'.env'.
2019-02-24 15:20:03 +08:00

24 lines
565 B
JavaScript

import fs from 'fs'
import browserify from 'browserify'
import envify from 'envify/custom'
import dotenv from 'dotenv'
import log from '@/helpers/log'
/**
* Build web app
*/
export default () => new Promise((resolve) => {
// read .env file from leon root directory
dotenv.config()
browserify('app/js/main.es6.js')
.transform('babelify')
.transform(envify(process.env))
.bundle()
.on('error', err => log.error(`[${err.name}] ${err.message}`))
.pipe(fs.createWriteStream('app/js/main.js'))
log.success('Web app built')
resolve()
})