-
Notifications
You must be signed in to change notification settings - Fork 703
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
Move uglify invocation into npm scripts and remove grunt #628
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Oh dear, windows' lack of globbing strikes again. I'll figure something out. |
Some notes:
So I think it's OK to explicitly list out the subdirectories for now. |
"build:font-awesome": "node scripts/build-fontawesome.js", | ||
"build:grunt": "grunt", | ||
"build:libs": "uglifyjs client/js/libs/*.js client/js/libs/jquery/*.js client/js/libs/handlebars/*.js -o client/js/libs.min.js --source-map client/js/libs.min.js.map --source-map-url libs.min.js.map -p relative", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you tried client/js/libs/*/*.js
and that didn't work, but have you tried client/js/libs/**/*.js
by any chance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, stupid question: do we want to uglify these? I don't think it matters too much in terms of performance.
EDIT: I also realize it makes things much simpler to load from the HTML file, so feel free to ignore if stupid comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a particularly good reason to uglify them other than for ease of loading, but webpack can fill this role once #609 lands and then we can drop uglify.
@@ -17,9 +17,9 @@ | |||
"scripts": { | |||
"coverage": "istanbul cover node_modules/mocha/bin/_mocha -r test/fixtures/env.js test/**/*.js", | |||
"start": "node index", | |||
"build": "npm run build:font-awesome && npm run build:grunt && npm run build:handlebars", | |||
"build": "npm-run-all build:*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am 99% sure we didn't use npm-run-all
for a reason here. I think it was that we didn't want to use it too much, hoping to get rid of it sooner or later, but oh well. It's pretty cool that it supports *
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm-run-all seems like a reasonable dependency at this point, but I can imagine simplifying things to a point where we can just use &&
(or &
for parallel) and drop a dependency. It's simple enough for now though, I think.
First of, amazing, I am so happy someone tackled this!
Guess what, I think we added AppVeyor right after the last mess up there as well :D
Agreed.
Added a comment to try with |
** doesn't even work on OSX, because npm scripts are executed with sh, not
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not cross-platform
Perhaps include uglifyjs in your webpack PR? Then the glob issues will be gone, and simplify it. |
This is cross-platform (appveyor passed, as did the OSX + Linux travis builds). Folding it into the webpack PR is cleaner, though, I agree :) |
I looked into folding this into #609, but ran into some problems. The libraries we include via the uglified libs.min.js are not CommonJS modules; they simply inject themselves into the global namespace. Webpack works by following IMHO this is still a win for now because we get to drop Grunt. As we further refactor the client we can shift stuff in libs/ over to CommonJS style and phase out uglify. |
That's why:
I get that by running |
Figured it out, had to run 👍 |
Awesome stuff, thanks @nornagon! |
Move uglify invocation into npm scripts and remove grunt
Unfortunately the uglifyjs command line ends up being a little unwieldy, but that's a small price to pay for dropping grunt!
If the 'watch' functionality is useful to folks, I can add one of the options from https://www.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/#watch