Update gulp to 4.0.0

This commit is contained in:
Ken-Håvard Lieng 2018-05-16 03:46:42 +02:00
parent 29a225ed13
commit 4fafe2b158
4 changed files with 577 additions and 265 deletions

View File

@ -17,10 +17,10 @@ matrix:
install: install:
- go get github.com/jteeuwen/go-bindata/... - go get github.com/jteeuwen/go-bindata/...
- cd client - cd client
- nvm install 10.0.0 - nvm install 10.1.0
- nvm use 10.0.0 - nvm use 10.1.0
- npm install -g yarn - npm install -g yarn
- yarn global add gulp - yarn global add gulp@next
- yarn --ignore-engines - yarn --ignore-engines
script: script:

View File

@ -9,6 +9,7 @@ var proxy = require('express-http-proxy');
var webpack = require('webpack'); var webpack = require('webpack');
var through = require('through2'); var through = require('through2');
var br = require('brotli'); var br = require('brotli');
var del = require('del');
function brotli(opts) { function brotli(opts) {
return through.obj(function(file, enc, callback) { return through.obj(function(file, enc, callback) {
@ -29,7 +30,11 @@ function brotli(opts) {
}); });
} }
gulp.task('js', function(cb) { function clean() {
return del(['dist']);
};
function js(cb) {
var config = require('./webpack.config.prod.js'); var config = require('./webpack.config.prod.js');
var compiler = webpack(config); var compiler = webpack(config);
@ -49,37 +54,42 @@ gulp.task('js', function(cb) {
cb(); cb();
}); });
}); }
gulp.task('fonts', function() { function config() {
return gulp.src('src/font/*').pipe(gulp.dest('dist/font')); return gulp.src('../config.default.toml').pipe(gulp.dest('dist'));
}); }
gulp.task('fonts:woff', function() { function fonts() {
return gulp.src('src/font/*(*.woff|*.woff2)').pipe(gulp.dest('dist/br/font')); return gulp.src('src/font/*(*.woff|*.woff2)').pipe(gulp.dest('dist/font'));
}); }
gulp.task('config', function() { function compressTTF() {
return gulp.src('../config.default.toml').pipe(gulp.dest('dist/br')); return gulp
}); .src(['src/font/*.ttf'])
.pipe(brotli({ quality: 11 }))
.pipe(gulp.dest('dist/font'));
}
function compress() { function compress() {
return gulp return gulp
.src(['dist/**/!(*.br|*.woff|*.woff2)', '!dist/{br,br/**}']) .src(['dist/!(*.toml)'])
.pipe(brotli({ quality: 11 })) .pipe(brotli({ quality: 11 }))
.pipe(gulp.dest('dist/br')); .pipe(gulp.dest('dist'));
} }
gulp.task('compress', ['js', 'fonts'], compress); function cleanup() {
return del(['dist/*(*.js|*.css)']);
}
gulp.task('bindata', ['compress', 'fonts:woff', 'config'], function(cb) { function bindata(cb) {
exec( exec(
'go-bindata -nomemcopy -nocompress -pkg assets -o ../assets/bindata.go -prefix "dist/br" dist/br/...', 'go-bindata -nomemcopy -nocompress -pkg assets -o ../assets/bindata.go -prefix "dist" dist/...',
cb cb
); );
}); }
gulp.task('dev', ['fonts'], function() { function serve() {
var config = require('./webpack.config.dev.js'); var config = require('./webpack.config.dev.js');
var compiler = webpack(config); var compiler = webpack(config);
var app = express(); var app = express();
@ -115,7 +125,13 @@ gulp.task('dev', ['fonts'], function() {
console.log('Listening at http://localhost:3000'); console.log('Listening at http://localhost:3000');
}); });
}); }
gulp.task('build', ['bindata']); const assets = gulp.parallel(js, config, fonts, compressTTF);
gulp.task('default', ['dev']);
const build = gulp.series(clean, assets, compress, cleanup, bindata);
const dev = gulp.series(clean, gulp.parallel(serve, fonts, gulp.series(config, bindata)));
gulp.task('build', build);
gulp.task('default', dev);

View File

@ -22,6 +22,7 @@
"brotli": "^1.3.1", "brotli": "^1.3.1",
"css-loader": "^0.28.0", "css-loader": "^0.28.0",
"cssnano": "^3.10.0", "cssnano": "^3.10.0",
"del": "^3.0.0",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0", "eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
@ -33,7 +34,7 @@
"eslint-plugin-react": "^7.7.0", "eslint-plugin-react": "^7.7.0",
"express": "^4.14.1", "express": "^4.14.1",
"express-http-proxy": "^1.2.0", "express-http-proxy": "^1.2.0",
"gulp": "^3.9.1", "gulp": "4.0.0",
"gulp-util": "^3.0.8", "gulp-util": "^3.0.8",
"jest": "^22.4.3", "jest": "^22.4.3",
"mini-css-extract-plugin": "^0.4.0", "mini-css-extract-plugin": "^0.4.0",
@ -52,6 +53,7 @@
"base64-arraybuffer": "^0.1.5", "base64-arraybuffer": "^0.1.5",
"es6-promise": "^4.2.4", "es6-promise": "^4.2.4",
"fontfaceobserver": "^2.0.9", "fontfaceobserver": "^2.0.9",
"formik": "1.0.0-beta.1",
"history": "4.5.1", "history": "4.5.1",
"immer": "^1.2.1", "immer": "^1.2.1",
"js-cookie": "^2.1.4", "js-cookie": "^2.1.4",

File diff suppressed because it is too large Load Diff