-2

enter image description here

gulp.task("uglify", function () {
  return (
    gulp
      .src("dist/alparslan-oto/main.js")
      .pipe(rename("main.js"))
      .pipe(sourcemaps.init())
      .pipe(uglify())
      // .pipe(sourcemaps.write()) // Inline source maps.
      // For external source map file:
      //.pipe(sourcemaps.write("./maps")) // In this case: lib/maps/bundle.min.js.map
      .pipe(gulp.dest("dist/"))
  );
});

I am using gulp uglify to compress javascript files(main,runtime,polly) in Angular. This has no effect, what would you recommend to shrink these files?

Ali Parlatti
  • 47
  • 1
  • 7
  • Well, your profiling tool is not really complaining about the actual size of your code, but rather about "removing unused code". You should probably check about your import of external libraries and whether they are treeshakable. You don't need uglify in order to achieve this, as this should be already visible during build time. – Fabian Strathaus Oct 14 '22 at 08:32
  • I'm using MDBootstrap and have already removed modules I don't use @Fabian Strathaus – Ali Parlatti Oct 14 '22 at 08:42
  • Can you show your output of `ng build` command? This should give a first hint on where the main size of your application is included. Are you using imports like `import * from ...` somewhere in your application? Maybe you should consider switching to explicit imports where possible – Fabian Strathaus Oct 14 '22 at 09:22

1 Answers1

0

enter image description here

ng build --prod --aot --hashing none output

But I solved the problem, I created the js sourcemap with uglify and the error went away

enter image description here

Ali Parlatti
  • 47
  • 1
  • 7
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 19 '22 at 07:40