Skip to content

Updated dependencies to latest and corrected code. #61

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
@@ -124,28 +124,29 @@ module.exports = function(opt) {
sourceMap: !!file.sourceMap
};

try {
mangled = uglify.minify(String(file.contents), uglifyOptions);
min_file.contents = new Buffer(mangled.code.replace(reSourceMapComment, ''));
} catch (e) {
this.emit('end');
return callback(new PluginError('gulp-minify', formatError(e, file)));
}

if (file.sourceMap) {
min_file.sourceMap = JSON.parse(mangled.map);
min_file.sourceMap.sourcesContent = originalSourceMap.sourcesContent;
min_file.sourceMap.sources = originalSourceMap.sources;
}

this.push(min_file);

if (options.noSource !== true) {
file.path = file.path.replace(jsExtensions, ext.src);
this.push(file);
}

callback();
(uglify.minify(String(file.contents), uglifyOptions))
.then((mangled) => {
min_file.contents = new Buffer(mangled.code.replace(reSourceMapComment, ''));

if (file.sourceMap) {
min_file.sourceMap = JSON.parse(mangled.map);
min_file.sourceMap.sourcesContent = originalSourceMap.sourcesContent;
min_file.sourceMap.sources = originalSourceMap.sources;
}

this.push(min_file);

if (options.noSource !== true) {
file.path = file.path.replace(jsExtensions, ext.src);
this.push(file);
}

callback();
})
.catch(e => {
this.emit('end');
callback(new PluginError('gulp-minify', formatError(e, file)));
})
}

return through.obj(minify);
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-minify",
"version": "3.1.0",
"version": "3.2.0",
"description": "Js minify plugin for gulp",
"main": "index.js",
"scripts": {
@@ -15,12 +15,12 @@
},
"author": "308512341@qq.com",
"dependencies": {
"ansi-colors": "^1.0.1",
"minimatch": "^3.0.2",
"plugin-error": "^0.1.2",
"terser": "^3.7.6",
"through2": "^2.0.3",
"vinyl": "^2.1.0"
"ansi-colors": "^4.1.3",
"minimatch": "^9.0.3",
"plugin-error": "^2.0.1",
"terser": "^5.26.0",
"through2": "^4.0.2",
"vinyl": "^3.0.0"
},
"license": "ISC",
"bugs": {
@@ -29,9 +29,9 @@
"homepage": "https://github.com/hustxiaoc/gulp-minify",
"readmeFilename": "README.md",
"devDependencies": {
"gulp": "^4.0.0",
"mocha": "^5.2.0",
"rimraf": "^2.6.2"
"gulp": "^4.0.2",
"mocha": "^10.2.0",
"rimraf": "^5.0.5"
},
"engines": {
"node": ">= 6.0.0"