minify: Does not work at all
Excuse me, I’m totally stuck.
That’s my main.jsx, it has to be converted to main.min.js:
import React, { Component } from "react";
import ReactDOM from "react-dom";
ReactDOM.render(<div>lala</div>,document.getElementById("root"));
That’s my build.js script:
var fs = require("fs");
var browserify = require("browserify");
browserify("./main.jsx")
.transform("babelify",{
presets: ["react","es2015","babili"]
})
.bundle()
.pipe(fs.createWriteStream("./main.min.js"));
These are my package.json dependencies:
"babel-minify": "^0.1.12",
"babel-plugin-uglify": "^1.0.2",
"babel-preset-babili": "0.0.4",
"babel-preset-es2015": "^6.16.0",
"babel-preset-react": "^6.16.0",
"babelify": "^7.3.0",
"bootstrap-sass": "^3.3.7",
"browserify": "^13.1.0",
"classnames": "^2.2.5",
"extend": "^3.0.0",
"mobx": "^2.5.2",
"mobx-react": "^3.5.7",
"mobx-react-devtools": "^4.2.6",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"uglify": "^0.1.5"
The result is main.min.jsx with filesize ~ 730KB. If I cut off babili from presets, the result is the same.
What do I do wrong?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 18 (3 by maintainers)
For those who are using babili with webpack, you can try babili-webpack-plugin.
node_modules
from being run through the babel-loader, babili optimizations are not applied to the excluded files as it doesn’t pass through the minifier.Comments
Also, one more thing to note is that by default the preset doesn’t remove comments. So in your babelrc or babel config that you use for babili, you can set
comments
tofalse
.I’ve not tried babili with browserify yet, so I can’t comment much there.
I was getting poor results too because it was only doing a per-file minification. The webpack edition matched the size of UglifyJS (thanks @boopathi)
Chart for the curious.
I have fallen down the same path. This does work for me, though: https://github.com/boopathi/babili-webpack-plugin.
I re-read the documentation I think the issue is that Babili isn’t operating the same way as UglifyJS or Closure Compiler. There’s only a small amount of minification due to Babili running per file rather than per bundle.