Comments (13)
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')
from 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.
from uglifyify.
I'm using it as follows:
browserify -d -t babelify -g [ uglifyify --no-sourcemap] files/*.jsx -o bundle.js
Browserify version: 9.0.3
Uglifyify version 3.0.1
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.
from uglifyify.
@AsaAyers my guess would be:
{
mangle: false,
compress: {
dead_code: true
}
}
Give that a shot and see if it works :)
from uglifyify.
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.
from uglifyify.
@hughsk
I am executing browserify with the following arguments:
bundler.transform(uglifyify, { global: true, mangle: true, compress: { sequences: true, dead_code: true, booleans: true } });
and I get the same code as if I executed:
bundler.transform(uglifyify, { global: true });
I think there is a problem.
from uglifyify.
@naorye a bunch of options are set to true by default, including compress
and mangle
. Try setting them to false you should see different output.
from uglifyify.
@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?
from uglifyify.
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?
from uglifyify.
+1 With the line-break problem
from uglifyify.
@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!
from uglifyify.
@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?
from uglifyify.
This is my bundle creation code:
var bundleEntries = [ './a/client.js', './b/client.js', './c/client.js' ],
bundleOutputs = [ './build/a/client.js', './build/b/client.js', './build/c/client.js' ],
commonOutput = './build/bundle.js',
b = null,
// The following runs scriptBuild() over all the returned scripts
write = filesWriter(scriptBuild, 1 + bundleOutputs.length, done)
params = { // Preare params
entries: bundleEntries, // All frames entries
transform: [ [ envify, { global: true } ] ],
extensions: [ '.jsx' ] // Add jsx for the module lookup machinery
};
if (process.env.DISTRIBUTION) {
params.transform.push([ 'uglifyify', { global: true, sourcemap: process.env.WATCH } ]);
}
if (process.env.WATCH) {
objectAssign(params, {
debug: true, // Gives us sourcemaps
cache: {}, // Requirement of watchify
packageCache: {}, // Requirement of watchify
fullPaths: true// Requirement of watchify
});
b = browserify(params);
b = watchify(b);
b.on('update', bundle);
} else {
b = browserify(params);
}
bundle();
function bundle() {
return b
.plugin('factor-bundle', { outputs: bundleOutputs.map(write) })
.on('error', function(err) { console.error(err) })
.bundle()
.pipe(write(commonOutput));
}
function scriptBuild(stream, filePath, dirname, basename) {
if (process.env.DISTRIBUTION) {
stream = stream
.pipe(uglify())
.pipe(rev())
.pipe(gulp.dest(dirname))
.pipe(rev.manifest());
}
return stream.pipe(gulp.dest(dirname));
}
from uglifyify.
Related Issues (20)
- Optional chaining support
- Update terser up to 4.8.1 HOT 1
- update to a maintained `through`?
- command line usage does not work HOT 2
- (v4) `ignore` is not a supported option HOT 2
- (v4) How to use "extensions" (-x, --exts) with node HOT 2
- Add CHANGELOG.md HOT 4
- Add better tests HOT 2
- Uglifyify fails when calling uglify HOT 3
- Missing command line entry
- --ignore flag being ignored in Jenkins environment HOT 2
- New dependency name: uglify-es => terser #1 HOT 2
- Fatal error: `ignore` is not a supported option while parsing file: HOT 2
- Update to [email protected]
- Inlined sourcemaps
- Global flag is ignored
- beautify does not work; should be an output option
- update package extend to >2.0.2 to remove package vurnerability HOT 1
- Wrong CLI option for Source Maps in README.md
- SyntaxError: 'return' outside of function while parsing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uglifyify.