|
|
@ -26,6 +26,16 @@ const pify = require('pify') |
|
|
|
const gulpMultiProcess = require('gulp-multi-process') |
|
|
|
const gulpMultiProcess = require('gulp-multi-process') |
|
|
|
const endOfStream = pify(require('end-of-stream')) |
|
|
|
const endOfStream = pify(require('end-of-stream')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const packageJSON = require('./package.json') |
|
|
|
|
|
|
|
const dependencies = Object.keys(packageJSON && packageJSON.dependencies || {}) |
|
|
|
|
|
|
|
const materialUIDependencies = ['@material-ui/core'] |
|
|
|
|
|
|
|
const reactDepenendencies = dependencies.filter(dep => dep.match(/react/)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const uiDependenciesToBundle = [ |
|
|
|
|
|
|
|
...materialUIDependencies, |
|
|
|
|
|
|
|
...reactDepenendencies, |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
function gulpParallel (...args) { |
|
|
|
function gulpParallel (...args) { |
|
|
|
return function spawnGulpChildProcess (cb) { |
|
|
|
return function spawnGulpChildProcess (cb) { |
|
|
|
return gulpMultiProcess(args, cb, true) |
|
|
|
return gulpMultiProcess(args, cb, true) |
|
|
@ -279,11 +289,32 @@ const buildJsFiles = [ |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
// bundle tasks
|
|
|
|
// bundle tasks
|
|
|
|
|
|
|
|
createTasksForBuildJsUIDeps({ dependenciesToBundle: uiDependenciesToBundle, filename: 'libs' }) |
|
|
|
createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:extension:js', devMode: true }) |
|
|
|
createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:extension:js', devMode: true }) |
|
|
|
createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:extension:js' }) |
|
|
|
createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:extension:js' }) |
|
|
|
createTasksForBuildJsMascara({ taskPrefix: 'build:mascara:js' }) |
|
|
|
createTasksForBuildJsMascara({ taskPrefix: 'build:mascara:js' }) |
|
|
|
createTasksForBuildJsMascara({ taskPrefix: 'dev:mascara:js', devMode: true }) |
|
|
|
createTasksForBuildJsMascara({ taskPrefix: 'dev:mascara:js', devMode: true }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createTasksForBuildJsUIDeps ({ dependenciesToBundle, filename }) { |
|
|
|
|
|
|
|
const destinations = browserPlatforms.map(platform => `./dist/${platform}`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bundleTaskOpts = Object.assign({ |
|
|
|
|
|
|
|
buildSourceMaps: true, |
|
|
|
|
|
|
|
sourceMapDir: '../sourcemaps', |
|
|
|
|
|
|
|
minifyBuild: true, |
|
|
|
|
|
|
|
devMode: false, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('build:extension:js:uideps', bundleTask(Object.assign({ |
|
|
|
|
|
|
|
label: filename, |
|
|
|
|
|
|
|
filename: `${filename}.js`, |
|
|
|
|
|
|
|
destinations, |
|
|
|
|
|
|
|
buildLib: true, |
|
|
|
|
|
|
|
dependenciesToBundle: uiDependenciesToBundle, |
|
|
|
|
|
|
|
}, bundleTaskOpts))) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, bundleTaskOpts = {} }) { |
|
|
|
function createTasksForBuildJsExtension ({ buildJsFiles, taskPrefix, devMode, bundleTaskOpts = {} }) { |
|
|
|
// inpage must be built before all other scripts:
|
|
|
|
// inpage must be built before all other scripts:
|
|
|
|
const rootDir = './app/scripts' |
|
|
|
const rootDir = './app/scripts' |
|
|
@ -326,6 +357,7 @@ function createTasksForBuildJs ({ rootDir, taskPrefix, bundleTaskOpts, destinati |
|
|
|
label: jsFile, |
|
|
|
label: jsFile, |
|
|
|
filename: `${jsFile}.js`, |
|
|
|
filename: `${jsFile}.js`, |
|
|
|
filepath: `${rootDir}/${jsFile}.js`, |
|
|
|
filepath: `${rootDir}/${jsFile}.js`, |
|
|
|
|
|
|
|
externalDependencies: jsFile === 'ui' && !bundleTaskOpts.devMode && uiDependenciesToBundle, |
|
|
|
destinations, |
|
|
|
destinations, |
|
|
|
}, bundleTaskOpts))) |
|
|
|
}, bundleTaskOpts))) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -402,6 +434,7 @@ gulp.task('build', |
|
|
|
'clean', |
|
|
|
'clean', |
|
|
|
'build:scss', |
|
|
|
'build:scss', |
|
|
|
gulpParallel( |
|
|
|
gulpParallel( |
|
|
|
|
|
|
|
'build:extension:js:uideps', |
|
|
|
'build:extension:js', |
|
|
|
'build:extension:js', |
|
|
|
'build:mascara:js', |
|
|
|
'build:mascara:js', |
|
|
|
'copy' |
|
|
|
'copy' |
|
|
@ -450,14 +483,25 @@ function zipTask (target) { |
|
|
|
|
|
|
|
|
|
|
|
function generateBundler (opts, performBundle) { |
|
|
|
function generateBundler (opts, performBundle) { |
|
|
|
const browserifyOpts = assign({}, watchify.args, { |
|
|
|
const browserifyOpts = assign({}, watchify.args, { |
|
|
|
entries: [opts.filepath], |
|
|
|
|
|
|
|
plugin: 'browserify-derequire', |
|
|
|
plugin: 'browserify-derequire', |
|
|
|
debug: opts.buildSourceMaps, |
|
|
|
debug: opts.buildSourceMaps, |
|
|
|
fullPaths: opts.buildWithFullPaths, |
|
|
|
fullPaths: opts.buildWithFullPaths, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!opts.buildLib) { |
|
|
|
|
|
|
|
browserifyOpts['entries'] = [opts.filepath] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let bundler = browserify(browserifyOpts) |
|
|
|
let bundler = browserify(browserifyOpts) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opts.buildLib) { |
|
|
|
|
|
|
|
bundler = bundler.require(opts.dependenciesToBundle) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opts.externalDependencies) { |
|
|
|
|
|
|
|
bundler = bundler.external(opts.externalDependencies) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// inject variables into bundle
|
|
|
|
// inject variables into bundle
|
|
|
|
bundler.transform(envify({ |
|
|
|
bundler.transform(envify({ |
|
|
|
METAMASK_DEBUG: opts.devMode, |
|
|
|
METAMASK_DEBUG: opts.devMode, |
|
|
|