Comments (11)
@onclave I've just updated the dependencies for brackets-minifier. Unfortunately it appears that UglifyJS3 does not support ES6 by default.
There's a bit of a roundabout method, however, to get ES6 minification that worked for me (and hopefully works for you):
-
Open Brackets and update brackets-minifier to the latest version (v3.0.0). Then go to Help -> Show Extensions Folder.
-
Go to
./user/brackets-minify/node
. -
Open
minifyjs.js
and modify line 7 to use"uglify-es"
instead of the original"uglify-js"
. -
Then open up a command prompt/terminal and navigate to the same folder. Run
npm install uglify-es
(you'll need to install npm first if you don't already have it).
Then, after reloading brackets, you should be able to minify your ES6 code. Keep in mind if you do update/re-install brackets-minifier in the future it will overwrite those changes you made.
If UglifyJS brings ES6 support to its main package I'll update it again. Until then I'm going to close this issue.
from brackets-minifier.
A few things:
- Have you set any directories to exclude?
- Can you give me an example of a filename of one of the
.js
files that isn't being minified? - Can you go to
Debug (Top menu bar) -> Show Developer Tools -> Console (Tab at the top)
and see if any errors show up (if so please include them here).
from brackets-minifier.
Hi,
1: I did exclude 2 directories, namely, /bower_components/
and /node_modules/
.
2: pms.controller.profile.js
, pms.controller.userdetails.js
, pms.controller.administrationdetails.js
are few among the many files that are not being minified. I tried to find a pattern among the file names that are not being minified, but there are none such. For example, pms.controller.administration.js
is getting minified to pms.controller.administration.min.js
, but pms.controller.administrationdetails.js
is not getting minified.
3: I cleared the console. Then I deleted all the minified files and did a minify project
. Upon doing so, this was the output on the console. I am attaching a screenshot of the console output.
Do let me know if you need more information. Thanks.
from brackets-minifier.
@onclave I believe the issue is that the files that aren't being minified have some syntax problem. I think the error Unexpected token operator =, expected punc ,
is being emitted because of an error in the syntax of the .js
files in question. The problem is that there is very little debug information (i.e. what line the problem is at in the .js
file being minified). In the future, I may upgrade this plugin to UglifyJS 3
and see if I can build in better debugging features.
For now, can you try to paste the code in pms.controller.administrationdetails.js
to https://jscompress.com/ and see if it is able to compress it properly without any errors? With any luck it'll find an error in the syntax that can be fixed.
It is possible this is a bug with the plugin - but doubtful. If https://jscompress.com/ doesn't find any issues I'll look into the plugin itself further.
from brackets-minifier.
@abagshaw so I checked as you asked, and yes the problem is with my js code (kind of). I am using some ES6 specific features in my code, especially default values for parameters in javascript methods. So, I would have to now re-write certain part of my code to use your minifier tool. Anyway, you could close this issue as resolved or mark it as a feature request so that your minifier can be ES6 compatible. Would really love to see the feature. And, thank you, once again, for your awesome minifier. :)
from brackets-minifier.
Ok sounds good - I'll try to add ES6 support when I have a chance.
from brackets-minifier.
@abagshaw I tried your method suggested above (and reloaded Brackets), but I still see
Unexpected token name «of», expected punc «;»
on my for ( var v of ... )
statements
So I guess it's manual minification for me :-\
from brackets-minifier.
@mblais Odd, when I switch brackets-minifier to use uglify-es I can minify for (var v of ...)
statements just fine.
Are you sure that your minifyjs.js
has require("uglify-es")
and not require("uglify-js")
on this line? And when you say "reloaded Brackets" have you shut it down and re-opened it, or just hit F5/Cmd+R
?
Might not be worth your trouble trying to fix this - but it's odd that it doesn't work.
from brackets-minifier.
My bad - I had not actually exited Brackets, only reloaded it.
Seems to work now, thanks! :-)
from brackets-minifier.
Great - glad it worked.
from brackets-minifier.
To minify ES6 i use Babel minify:
I did the following:
on minifyjs.js: (/brackets-minify/node/minifyjs.js)
Add var BabelMinJS = require("babel-minify");
on function minifyJS:
minified = BabelMinJS(text, {mangle: {keepClassName: true}}).code;
on CMD navigate to:
C:\Users<user>\AppData\Roaming\Brackets\extensions\user\brackets-minify\node\
and run:
npm install babel-minify
on your code press: ctrl+alt+M
best regards!
from brackets-minifier.
Related Issues (20)
- Features of this minifier HOT 5
- stopped working HOT 2
- Preserve License Comments HOT 3
- Concatenate on Save Option HOT 2
- Error when ES6 Template literals minify HOT 1
- JSON File HOT 1
- Variable concatSavePath is returning a duplicate path HOT 1
- concat feature not working HOT 4
- ES6 "for..of" not supported? HOT 3
- URL minified HOT 5
- JS minification doesn't work HOT 15
- Minifier create new min file HOT 3
- Minifying error HOT 1
- Does not minify JSON
- Standard command minified project, not single file
- File contents "undefined" HOT 3
- Status text colour
- save without .min HOT 1
- Minifying javascript with backticks results in undefined
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 brackets-minifier.