Improve build task

This commit is contained in:
Boris Kubiak 2018-01-11 08:35:53 +01:00
parent 62222bc76f
commit 631f247dac
3 changed files with 18 additions and 32 deletions

View file

@ -8,7 +8,6 @@ const source = require('vinyl-source-stream');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
// Browserify
@ -35,8 +34,7 @@ gulp.task('build-js', ['browserify'], cb => {
gulp.src(['js/index.js', 'js/bundle.js']),
babel({presets: ['env'], plugins: ['@babel/plugin-transform-object-assign']}),
uglify(),
rename({extname: '.min.js'}),
gulp.dest('build/js')
gulp.dest('js')
], cb);
});
@ -50,25 +48,19 @@ gulp.task('build-css', ['sass'], cb => {
cascade: false
}),
cleanCSS({compatibility: 'ie8'}),
rename({extname: '.min.css'}),
gulp.dest('build/css')
], cb);
});
gulp.task('replace-path', cb => {
pump([
gulp.src('index.html'),
replace('css/stylesheet.css', 'build/css/stylesheet.min.css'),
replace('js/index.js', 'build/js/index.min.js'),
gulp.dest('./'),
gulp.src('js/index.js'),
replace('js/bundle.js', 'build/js/bundle.min.js'),
gulp.dest('js')
gulp.dest('css')
], cb);
});
// Build app
gulp.task('build', ['replace-path', 'build-js', 'build-css']);
gulp.task('build', ['build-js', 'build-css'], cb => {
pump([
gulp.src('.gitignore'),
replace('js/bundle.js', ''),
replace('css/stylesheet.css', ''),
gulp.dest('./')
], cb);
});
// Watch changes and compile on the fly
gulp.task('watch', () => {

21
package-lock.json generated
View file

@ -1312,7 +1312,7 @@
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"requires": {
"bn.js": "4.11.8",
"randombytes": "2.0.5"
"randombytes": "2.0.6"
}
},
"browserify-sign": {
@ -1811,7 +1811,7 @@
"inherits": "2.0.3",
"pbkdf2": "3.0.14",
"public-encrypt": "4.0.0",
"randombytes": "2.0.5",
"randombytes": "2.0.6",
"randomfill": "1.0.3"
}
},
@ -2039,7 +2039,7 @@
"requires": {
"bn.js": "4.11.8",
"miller-rabin": "4.0.1",
"randombytes": "2.0.5"
"randombytes": "2.0.6"
}
},
"doctrine": {
@ -3208,11 +3208,6 @@
"vinyl-sourcemaps-apply": "0.2.1"
}
},
"gulp-rename": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz",
"integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc="
},
"gulp-replace": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-0.6.1.tgz",
@ -5467,7 +5462,7 @@
"browserify-rsa": "4.0.1",
"create-hash": "1.1.3",
"parse-asn1": "5.1.0",
"randombytes": "2.0.5"
"randombytes": "2.0.6"
}
},
"pump": {
@ -5520,9 +5515,9 @@
"integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM="
},
"randombytes": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz",
"integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==",
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
"integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
"requires": {
"safe-buffer": "5.1.1"
}
@ -5532,7 +5527,7 @@
"resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.3.tgz",
"integrity": "sha512-YL6GrhrWoic0Eq8rXVbMptH7dAxCs0J+mh5Y0euNekPPYaxEmdVGim6GdoxoRzKW2yJoU8tueifS7mYxvcFDEQ==",
"requires": {
"randombytes": "2.0.5",
"randombytes": "2.0.6",
"safe-buffer": "5.1.1"
}
},

View file

@ -11,7 +11,6 @@
"gulp-autoprefixer": "^4.0.0",
"gulp-babel": "^7.0.0",
"gulp-clean-css": "^3.9.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.6.1",
"gulp-sass": "^3.1.0",
"gulp-uglify": "^3.0.0",