webpack-contrib / babel-minify-webpack-plugin

[DEPRECATED] Babel Minify Webpack Plugin
MIT License
491 stars 44 forks source link

named functions excluded #72

Closed BernardA closed 6 years ago

BernardA commented 6 years ago

The plugin seems to exclude all named functions from minified output.

Without minification the named functions exist in the webpack output, but they are no longer there when the plugin is applied.

This is one instance of a function included in myfile.js:

 `function scrollToAnchor(aid) {  
        var aTag = $("a[name='" + aid + "']");
       $('html,body').animate({
           scrollTop: aTag.offset().top
       }, 'slow');
   }
 `

On the same file, this showed up correctly on the minified version:

 `$(document).ready(function() {
       $(document).ajaxSend(function() {
            $("#spinner").show();
       });
      $(document).ajaxStop(function() {
            $("#spinner").hide();
      });
    });
 `

webpack.config.js:

 `const MinifyPlugin = require("babel-minify-webpack-plugin");
   .....
   module.exports = {
       ...
        plugins: [
            new MinifyPlugin(),
       ...
 `

babel.rc

 `{
 "presets": [
 ["env", 
 {
  "modules": false,
  "useBuiltIns": true,
  "targets": {
    "browsers": ["last 2 versions", "safari >= 7"]
  }
 }],
 "react",
 "es2015"
 ],
 "plugins": [
  "transform-object-rest-spread", 
  "transform-react-jsx",
  "transform-runtime"
  ],
"comments": false
  }
 `

Thanks

alexander-akait commented 6 years ago

@BernardA plugin don't do minification directly, we just use babel-preset-minify, please create issue there. Thanks!