aboutsummaryrefslogtreecommitdiffstats
path: root/gulpfile.js
diff options
context:
space:
mode:
authorThomas <tmashuang@gmail.com>2018-03-10 07:01:48 +0800
committerThomas <tmashuang@gmail.com>2018-03-10 07:01:48 +0800
commitd5b1d6182ba73b28efd6862034038156c3e596c1 (patch)
tree8bebaedc1f9c95bb2d17b12be2fd16d50f75ad0f /gulpfile.js
parent0db4ba1086f56422752dd4b9e3754a273d23a866 (diff)
parent634e5d8f55efc6c307a867556116a565eee21b58 (diff)
downloadtangerine-wallet-browser-d5b1d6182ba73b28efd6862034038156c3e596c1.tar.gz
tangerine-wallet-browser-d5b1d6182ba73b28efd6862034038156c3e596c1.tar.zst
tangerine-wallet-browser-d5b1d6182ba73b28efd6862034038156c3e596c1.zip
Merge branch 'master' into selenium-e2e
Diffstat (limited to 'gulpfile.js')
-rw-r--r--gulpfile.js74
1 files changed, 66 insertions, 8 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 4c36ff7d4..adfb148a9 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -21,10 +21,18 @@ var replace = require('gulp-replace')
var mkdirp = require('mkdirp')
var asyncEach = require('async/each')
var exec = require('child_process').exec
+var sass = require('gulp-sass')
+var autoprefixer = require('gulp-autoprefixer')
+var gulpStylelint = require('gulp-stylelint')
+var stylefmt = require('gulp-stylefmt')
+var uglify = require('gulp-uglify-es').default
+var babel = require('gulp-babel')
+
var disableDebugTools = gutil.env.disableDebugTools
var debug = gutil.env.debug
+
// browser reload
gulp.task('dev:reload', function() {
@@ -171,7 +179,7 @@ gulp.task('deps', function (cb) {
gulp.task('lint', function () {
// Ignoring node_modules, dist/firefox, and docs folders:
- return gulp.src(['app/**/*.js', 'ui/**/*.js', 'mascara/src/*.js', 'mascara/server/*.js', '!node_modules/**', '!dist/firefox/**', '!docs/**', '!app/scripts/chromereload.js', '!mascara/test/jquery-3.1.0.min.js'])
+ return gulp.src(['app/**/*.js', '!app/scripts/vendor/**/*.js', 'ui/**/*.js', 'mascara/src/*.js', 'mascara/server/*.js', '!node_modules/**', '!dist/firefox/**', '!docs/**', '!app/scripts/chromereload.js', '!mascara/test/jquery-3.1.0.min.js'])
.pipe(eslint(fs.readFileSync(path.join(__dirname, '.eslintrc'))))
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
@@ -203,14 +211,55 @@ const jsFiles = [
'popup',
]
+// scss compilation and autoprefixing tasks
+
+gulp.task('build:scss', function () {
+ return gulp.src('ui/app/css/index.scss')
+ .pipe(sourcemaps.init())
+ .pipe(sass().on('error', sass.logError))
+ .pipe(sourcemaps.write())
+ .pipe(autoprefixer())
+ .pipe(gulp.dest('ui/app/css/output'))
+})
+gulp.task('watch:scss', function() {
+ gulp.watch(['ui/app/css/**/*.scss'], gulp.series(['build:scss']))
+})
+
+gulp.task('lint-scss', function() {
+ return gulp
+ .src('ui/app/css/itcss/**/*.scss')
+ .pipe(gulpStylelint({
+ reporters: [
+ {formatter: 'string', console: true}
+ ],
+ fix: true,
+ }));
+});
+
+gulp.task('fmt-scss', function () {
+ return gulp.src('ui/app/css/itcss/**/*.scss')
+ .pipe(stylefmt())
+ .pipe(gulp.dest('ui/app/css/itcss'));
+});
+
// bundle tasks
var jsDevStrings = jsFiles.map(jsFile => `dev:js:${jsFile}`)
var jsBuildStrings = jsFiles.map(jsFile => `build:js:${jsFile}`)
jsFiles.forEach((jsFile) => {
- gulp.task(`dev:js:${jsFile}`, bundleTask({ watch: true, label: jsFile, filename: `${jsFile}.js` }))
- gulp.task(`build:js:${jsFile}`, bundleTask({ watch: false, label: jsFile, filename: `${jsFile}.js` }))
+ gulp.task(`dev:js:${jsFile}`, bundleTask({
+ watch: true,
+ label: jsFile,
+ filename: `${jsFile}.js`,
+ isBuild: false
+ }))
+ gulp.task(`build:js:${jsFile}`, bundleTask({
+ watch: false,
+ label: jsFile,
+ filename: `${jsFile}.js`,
+ isBuild: true
+ }))
})
// inpage must be built before all other scripts:
@@ -244,12 +293,18 @@ gulp.task('zip:edge', zipTask('edge'))
gulp.task('zip:opera', zipTask('opera'))
gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge', 'zip:opera'))
+// set env var for production
+gulp.task('apply-prod-environment', function(done) {
+ process.env.NODE_ENV = 'production'
+ done()
+});
+
// high level tasks
-gulp.task('dev', gulp.series('dev:js', 'copy', gulp.parallel('copy:watch', 'dev:reload')))
+gulp.task('dev', gulp.series('build:scss', 'dev:js', 'copy', gulp.parallel('watch:scss', 'copy:watch', 'dev:reload')))
-gulp.task('build', gulp.series('clean', gulp.parallel('build:js', 'copy', 'deps')))
-gulp.task('dist', gulp.series('build', 'zip'))
+gulp.task('build', gulp.series('clean', 'build:scss', gulp.parallel('build:js', 'copy')))
+gulp.task('dist', gulp.series('apply-prod-environment', 'build', 'zip'))
// task generators
@@ -276,7 +331,7 @@ function zipTask(target) {
return () => {
return gulp.src(`dist/${target}/**`)
.pipe(zip(`metamask-${target}-${manifest.version}.zip`))
- .pipe(gulp.dest('builds'));
+ .pipe(gulp.dest('builds'))
}
}
@@ -342,7 +397,6 @@ function bundleTask(opts) {
throw err
}
})
-
// convert bundle stream to gulp vinyl stream
.pipe(source(opts.filename))
// inject variables into bundle
@@ -352,6 +406,10 @@ function bundleTask(opts) {
// sourcemaps
// loads map from browserify file
.pipe(gulpif(debug, sourcemaps.init({ loadMaps: true })))
+ // Minification
+ .pipe(gulpif(opts.isBuild, uglify({
+ mangle: { reserved: [ 'MetamaskInpageProvider' ] },
+ })))
// writes .map file
.pipe(gulpif(debug, sourcemaps.write('./')))
// write completed bundles