M
M
Maxim Tarabrin2017-10-29 19:34:26
Node.js
Maxim Tarabrin, 2017-10-29 19:34:26

Why is UglifyJS not working?

Why are the files not merged? what's wrong? I am attaching the code below:

var uglifyjs = require('uglify-js');
var fs = require('fs');

var appClientFiles = [
  "app_client/app.js",
  "app_client/home/home.controller.js",
  "app_client/common/services/geolocation.service.js",
  "app_client/common/services/loc8rData.service.js",
  "app_client/common/filters/formatDistance.filter.js",
  "app_client/common/directives/ratingStars/ratingStars.directive.js"
];

var uglified = uglifyjs.minify(appClientFiles,{compress: false});
console.log(uglified.code);
fs.writeFile('public/angular/loc8r.min.js',uglified.code, function(err){
  if(err){
    console.log(err);
  }else{
    console.log('Script generated and saved: loc8r.min.js');
  }
});

I output it in the console to see what was concatenated there, and there the paths were stupidly concatenated.
app_client/app.js;app_client/home/home.controller.js;app_client/common/services/geolocation.service.js;app_client/common/services/loc8rData.service.js;app_client/common/filters/
formatDistance.filter.js;app_client/common/directives/ratingStars/ratingStars.directive.js;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Kit, 2017-10-29
@padr1no

Naturally. You give it an array of code. gulp thinks it's code because uglify is a variable minification and renaming plugin. The bundler is browserify, requirejs, webpack. Here, catch a normal
UPD config
But if you need to stupidly concatenate browser js that does not affect package json and its dependencies, then you can get by with this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question