[go: up one dir, main page]

Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How to custom uglifyOptions? #1951

Closed
chiaweilee opened this issue Feb 11, 2019 · 3 comments
Closed

How to custom uglifyOptions? #1951

chiaweilee opened this issue Feb 11, 2019 · 3 comments

Comments

@chiaweilee
Copy link
Member

I used chainWebpack, eg:

module.exports = function (config, { webpack }) {
  config.merge({
    plugin: {
      'banner': {
        plugin: webpack.BannerPlugin,
        args: [
          {
            entryOnly: true,
            banner: `${process.env.npm_package_name} v${process.env.npm_package_version}\n` +
                '(c) 2019 +v\n' +
                'Released under the MIT License.'
          }
        ]
      }
    }
  });
}

it never work.

and I found node_modules/af-webpack/lib/getConfig/uglifyOptions.js:59 comments: false,

so what can I do now?

@i5ting
Copy link
Member
i5ting commented Feb 11, 2019

use uglifyjs-webpack-plugin instead

chainWebpack(config, { webpack }) {
  config.merge({
    plugin: {
      install: {
        plugin: require('uglifyjs-webpack-plugin'),
        args: [{
          sourceMap: false,
          uglifyOptions: {
            compress: {
              // remove `console.*`
              drop_console: true,
            },
            output: {
              // whether to actually beautify the output
              beautify: false,
              // remove all comments
              comments: false,
            },
          }
        }]
      }
    }
  })
}

https://umijs.org/config/#chainwebpack

@sorrycc
Copy link
Member
sorrycc commented Feb 11, 2019

Checkout https://umijs.org/config/#uglifyjsoptions for detail.

@sorrycc sorrycc closed this as completed Feb 11, 2019
@chiaweilee
Copy link
Member Author
// .umirc.js
export default {
  uglifyJSOptions: { uglifyOptions: { output: { comments: true } } },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants