-
Notifications
You must be signed in to change notification settings - Fork 61
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
Setting uglifyJS options #26
Comments
From the CLI, you can use subarg syntax :) browserify index.js -t [ uglifyify --mangle --compress [ --sequences --dead_code --booleans ] ] Or if working with browserify as a module: var browserify = require('browserify')
var bundler = browserify('index.js')
bundler.transform({
mangle: true,
compress: {
sequences: true,
dead_code: true
booleans: true
}
}, 'uglifyify') |
Do you know if there's a set of configs that will only trim dead code? I'd like to combine this with envify to remove some requires, but something just doesn't seem right about uglifying the code in the bundle. And I'm already running uglify on the final output. |
@AsaAyers my guess would be: {
mangle: false,
compress: {
dead_code: true
}
} Give that a shot and see if it works :) |
It still collapses everything onto one line. Thanks for trying though :) I tried looking through the list of transforms again and I think unreachable-branch-transform is really what I'd prefer to use. |
@hughsk and I get the same code as if I executed: I think there is a problem. |
@naorye a bunch of options are set to true by default, including |
@weilu You right. The thing is that after using uglifyify, I get several uglyfied files concatenated into one file with a lot of line breaks. So I am using gulp-uglify after browserify done it's work. Is it the right way to do it? |
You shouldn't need to run it through gulp-uglify again. You are not the first person to report the line breaks problem. Unfortunately I don't have the same issue with my package. Is it possible for you to note down the exact steps to reproduce the line break issue? |
+1 With the line-break problem |
@ribeiroct +1's are generally not as useful as a step-by-step repro of what causes the issue for you. Would you mind posting one so we can help resolve this issue? Thanks! |
I'm using it as follows:
Browserify version: 9.0.3 Breaklines seem to be introduced after some of the function opening brackets. I'm using it on a reactjs project. To solve it i'm doing another pass with uglifyjs in the end. Can babelify be having an effect on the process? I'm not sure. |
@ribeiroct @naorye I don't have your source code so I'm not sure how to reproduce this. Can either of you give me the smallest reproducible source before bundle? |
This is my bundle creation code:
|
How can one send options to uglify js with this transform?
Such as:
The text was updated successfully, but these errors were encountered: