Gulp noob hier und ich sehe seltsames Verhalten mit gulp-uglify.gulp-ugify stream error nach gulp-rename
Hier ist meine Aufgabe:
var gulp = require ("gulp");
var util = require ("gulp-util");
var clean = require ("gulp-clean");
var cleanCSS = require ("gulp-clean-css");
var debug = require ("gulp-debug");
var filesize = require ("gulp-filesize");
var rename = require ("gulp-rename");
var sass = require ("gulp-ruby-sass");
var browserify = require (BROWSERIFY);
var source = require ("vinyl-source-stream");
var buffer = require ("vinyl-buffer");
var sourceMaps = require("gulp-sourcemaps");
var babelify = require ("babelify");
var uglify = require ("gulp-uglify");
var concatFileNames = require ("gulp-concat-filenames");
var header = require ("gulp-header");
function browserifyTask() {
return browserify ("./app/main.js")
.transform(babelify)
.bundle()
.pipe (source("main.js"))
.pipe (buffer())
.pipe (sourceMaps.init({loadMaps: true}))
.pipe (sourceMaps.write("./")) // Ensure the source map gets written
.pipe (gulp.dest("./public/js"))
// Now do production build stuff
.pipe (rename("main.min.js"))
.pipe (sourceMaps.init({loadMaps: true}))
.pipe (uglify().on ("error", util.log))
.pipe (sourceMaps.write("./")) // Ensure the source map gets written
.pipe (gulp.dest("./public/js"))
}
Die Idee ist, normal (nicht-minimierte) JS und eine verkleinerte Version zu produzieren.
Allerdings wirft uglify einen Fehler:
[16:20:26] Using gulpfile C:\play\untitled\gulpfile.js
[16:20:26] Starting 'browserify'...
[16:20:28] { [Error: C:\play\untitled\public\js\main.min.js: Unexpected token: punc (:)]
message: 'C:\\play\\untitled\\public\\js\\main.min.js: Unexpected token: punc (:)',
fileName: 'C:\\play\\untitled\\public\\js\\main.min.js',
lineNumber: 1,
stack: 'Error\n at new JS_Parse_Error (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:1526:18)\n at js_error (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:1534:11)\n at croak (eval at <anonymo
us> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:2026:9)\n at token_error (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:2034:9)\n at unexpected (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tool
s\\node.js:22:1), <anonymous>:2040:9)\n at semicolon (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:2060:56)\n at simple_statement (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:2240:73)\n at ev
al (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify- js\\tools\\node.js:22:1), <anonymous>:2093:47)\n at eval (eval at <anonymous> (C:\\play\\untitled\\node_modules\\uglify-js\\tools\\node.js:22:1), <anonymous>:2073:24)\n at block_ (eval at <anonymous> (C:\\play\\untitled\\node_modules\\ugli
fy-js\\tools\\node.js:22:1), <anonymous>:2353:20)',
showStack: false,
showProperties: true,
plugin: 'gulp-uglify' }
Es wäre es scheint nicht, etwas über die JS mag es verrohrt ist wird aber verunstalten den Fehler nicht aus, wenn es vor dem ersten gulp.dest genannt wird () ruf an (und ich bekomme einen verfälschten Code).
This post haben angegeben, dass Quellkarten möglicherweise ein Problem darstellen, und verwendet gulp-ignore, um sie auszuschließen. Versuchte es und es hat nicht funktioniert; gleicher Fehler
Habe ich hier etwas offensichtlich übersehen?
Danke, Jeff