gulpのminifyプロセスの改善 (#5624)

* Use terser instead of uglify

* Use gulp-clean-css instead of gulp-cssnano

* isProduction分岐を削除
This commit is contained in:
MeiMei 2019-12-12 00:37:58 +09:00 committed by syuilo
parent fe9371f06c
commit d18291cf0c
3 changed files with 112 additions and 750 deletions

View File

@ -3,27 +3,22 @@
*/
import * as gulp from 'gulp';
import * as gutil from 'gulp-util';
import * as ts from 'gulp-typescript';
const sourcemaps = require('gulp-sourcemaps');
import tslint from 'gulp-tslint';
const cssnano = require('gulp-cssnano');
const stylus = require('gulp-stylus');
import * as uglifyComposer from 'gulp-uglify/composer';
import * as rimraf from 'rimraf';
import * as chalk from 'chalk';
import * as rename from 'gulp-rename';
import * as mocha from 'gulp-mocha';
import * as replace from 'gulp-replace';
const uglifyes = require('uglify-es');
const cleanCSS = require('gulp-clean-css');
const terser = require('gulp-terser');
const locales = require('./locales');
const uglify = uglifyComposer(uglifyes, console);
const env = process.env.NODE_ENV || 'development';
const isProduction = env === 'production';
const isDebug = !isProduction;
const isDebug = env !== 'production';
if (isDebug) {
console.warn(chalk.yellow.bold('WARNING! NODE_ENV is not "production".'));
@ -101,17 +96,15 @@ gulp.task('build:client:script', () => {
.pipe(replace('VERSION', JSON.stringify(client.version)))
.pipe(replace('ENV', JSON.stringify(env)))
.pipe(replace('LANGS', JSON.stringify(Object.keys(locales))))
.pipe(isProduction ? uglify({
.pipe(terser({
toplevel: true
} as any) : gutil.noop())
}))
.pipe(gulp.dest('./built/client/assets/'));
});
gulp.task('build:client:styles', () =>
gulp.src('./src/client/app/init.css')
.pipe(isProduction
? (cssnano as any)()
: gutil.noop())
.pipe(cleanCSS())
.pipe(gulp.dest('./built/client/assets/'))
);
@ -130,7 +123,7 @@ gulp.task('copy:client', () =>
gulp.task('doc', () =>
gulp.src('./src/docs/**/*.styl')
.pipe(stylus())
.pipe((cssnano as any)())
.pipe(cleanCSS())
.pipe(gulp.dest('./built/docs/assets/'))
);

View File

@ -26,7 +26,6 @@
"format": "gulp format"
},
"resolutions": {
"gulp-cssnano/cssnano/postcss-svgo/svgo/js-yaml": "^3.13.1",
"https-proxy-agent": "^3.0.0",
"lodash": "^4.17.13"
},
@ -50,8 +49,6 @@
"@types/gulp-mocha": "0.0.32",
"@types/gulp-rename": "0.0.33",
"@types/gulp-replace": "0.0.31",
"@types/gulp-uglify": "3.0.6",
"@types/gulp-util": "3.0.34",
"@types/is-url": "1.2.28",
"@types/js-yaml": "3.12.1",
"@types/jsdom": "12.2.4",
@ -133,16 +130,15 @@
"file-type": "12.4.0",
"fluent-ffmpeg": "2.1.2",
"gulp": "4.0.2",
"gulp-cssnano": "2.1.3",
"gulp-clean-css": "4.2.0",
"gulp-mocha": "7.0.2",
"gulp-rename": "1.4.0",
"gulp-replace": "1.0.0",
"gulp-sourcemaps": "2.6.5",
"gulp-stylus": "2.7.0",
"gulp-terser": "1.2.0",
"gulp-tslint": "8.1.4",
"gulp-typescript": "5.0.1",
"gulp-uglify": "3.0.2",
"gulp-util": "3.0.8",
"hard-source-webpack-plugin": "0.13.1",
"html-minifier": "4.0.0",
"http-signature": "1.3.1",
@ -233,7 +229,6 @@
"tslint-sonarts": "1.9.0",
"typeorm": "0.2.20",
"typescript": "3.7.2",
"uglify-es": "3.3.9",
"ulid": "2.3.0",
"url-loader": "2.3.0",
"uuid": "3.3.3",

832
yarn.lock

File diff suppressed because it is too large Load Diff