Open Luncher opened 8 years ago
Hey @Luncher! I tried my best to reproduce your gulp task to see what is going on.
What is the result of gameFiles.concat(commonFiles)
? Does that concatenate the contents of those files? gulp.src
takes in a glob string rather than the contents of files.
Also, I got an exception from uglify unless I wrote it like this:
var min = rename('gamebuilder.js')
.pipe(uglify())
.pipe(gzip({append: true}));
Does that make a difference for you?
Hey @jstuckey thank you for your reply, the gameFiles.concat(commonFiles) result is file path, not the file contents.
I am gulp beginners, I think this is the relative lack of learning materials .
Can you help me explain the following two methods are different?
var min = rename('gamebuilder.js') .pipe(uglify()) .pipe(gzip({append: true}));
var min = rename('gamebuilder.js'); min.pipe(uglify()) .pipe(gzip({append: true}));
The value that gets assigned to min
is different. In the original, the value of min
is only the rename
stream. In the new version, the value of min
is the pipeline of the three streams (rename
, uglify
, and gzip
)
For example:
var min1 = rename('gamebuilder.js');
min1.pipe(uglify())
.pipe(gzip({append: true}));
var min2 = rename('gamebuilder.js')
.pipe(uglify())
.pipe(gzip({append: true}));
console.log(min1);
console.log(min2);
console.log(min1 === min2);
got it, but I still do not understand why can not generate gzip.
I was able to generate a gzipped file using
var min = rename('gamebuilder.js')
.pipe(uglify())
.pipe(gzip({append: true}));
Does that not work for you?
var fs = require('fs'); var path = require('path'); var gulp = require('gulp'); var gzip = require('gulp-gzip'); var gutil = require('gulp-util'); var uglify = require('gulp-uglify'); var concat = require('gulp-concat'); var rename = require('gulp-rename'); var mirror = require('gulp-mirror'); var sourcemaps = require('gulp-sourcemaps');
gulp.task('build-ide', function() { var distDir = './js'; var commonFiles = fs.readFileSync('build/common_files', 'utf8').split('\n'); var gameFiles = fs.readFileSync('build/gamebuilder_files', 'utf8').split('\n');
});
the result cant generate min files, but can not gzip files,