Skip to content

Commit

Permalink
fix gulp error on building dashboard (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
HiroyasuNishiyama authored Feb 26, 2023
1 parent 454a163 commit 0d81de4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
27 changes: 23 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ var
htmlreplace = require('gulp-html-replace'),
ghtmlSrc = require('gulp-html-src'),
minifyHTML = require('gulp-htmlmin'),
gulpif = require('gulp-if'),
gjscs = require('gulp-jscs'),
jshint = require('gulp-jshint'),
gmanifest = require('gulp-manifest3'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
sass = require('gulp-sass')(require('sass')),
uglify = require('gulp-uglify'),
gutil = require('gulp-util'),
path = require('path'),
streamqueue = require('streamqueue');
streamqueue = require('streamqueue'),
map = require("map-stream"),
terser = require("terser");

var vendorPrefix = "vendor/";
function getFileName(attr, node) {
Expand Down Expand Up @@ -81,7 +81,26 @@ function js() {
.pipe(gulp.dest('dist/'));

return streamqueue({ objectMode:true }, scripts, templates)
.pipe(gulpif(/[.]min[.]js$/, gutil.noop(), uglify()))
.pipe(map((data, cb) => {
const path = data.path;
const contents = data.contents;
if (/\.min\.js$/.test(path)) {
cb(null, data);
}
else {
(async () => {
try {
const code = await terser.minify(contents.toString('utf8'));
const result = Buffer.from(code.code);
data.contents = result;
cb(null, data);
}
catch (e) {
cb("error: " +e.toString());
}
})();
}
}))
.pipe(concat('app.min.js'))
.pipe(header(fs.readFileSync('license.js')))
.pipe(eol('\n'))
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,25 @@
"gulp-html-replace": "^1.6.2",
"gulp-html-src": "^1.0.0",
"gulp-htmlmin": "^5.0.1",
"gulp-if": "^3.0.0",
"gulp-jscs": "^4.1.0",
"gulp-jshint": "^2.1.0",
"gulp-manifest3": "^0.1.2",
"gulp-rename": "^1.4.0",
"gulp-replace": "^1.1.4",
"gulp-sass": "^5.1.0",
"gulp-uglify": "~3.0.2",
"gulp-util": "^3.0.8",
"jquery": "~3.6.2",
"jshint": "~2.13.6",
"justgage": "~1.6.1",
"less": "^3.13.1",
"map-stream": "^0.0.7",
"material-design-icons-iconfont": "^6.7.0",
"moment": "~2.29.4",
"sass": "^1.57.1",
"sprintf-js": "^1.1.2",
"streamqueue": "~1.1.2",
"svg-morpheus": "^0.3.0",
"terser": "^5.16.5",
"tinycolor2": "1.4.2",
"weather-icons-lite": "^1.6.1"
},
Expand Down

0 comments on commit 0d81de4

Please sign in to comment.