Grunt Tool to package node-webkit

13 views
Skip to first unread message

Steffen

unread,
Aug 13, 2013, 11:33:14 AM8/13/13
to node-...@googlegroups.com
Hey there,

I've been using grunt a lot lately for a lot of my projects to streamline the build process. So I wrote a grunt plugin that downloads a specified node webkit prebuilt binary and packages the app for the mac/win/linux platform.

Maybe this is helpful for someone if you are also using grunt: https://npmjs.org/package/grunt-node-webkit-builder

This is the first release so there may be some bugs :)

Steffen

Marc Torruella

unread,
Aug 13, 2013, 11:35:23 AM8/13/13
to node-...@googlegroups.com
i was planning to start using grunt in my next project so... thank you sir!


--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alex Casanova

unread,
Aug 13, 2013, 1:05:25 PM8/13/13
to node-...@googlegroups.com
Wow, what a time saver. If I'm reading this correctly, Do I need to be on a windows machine to build for windows?

Steffen

unread,
Aug 13, 2013, 1:46:58 PM8/13/13
to node-...@googlegroups.com
No, that's the point of it. You can be on your system of choice and build for every plattform.
I'm developing on a mac and normally build for mac and windows.

Michael Winser

unread,
Aug 13, 2013, 1:51:08 PM8/13/13
to node-...@googlegroups.com
We gave up on grunt and switched to jake.  We have a single jakefile that can build for windows, linux and mac.  We have some secondary binaries that are platform specific.  We build those separately and check them into the project so that the day to day build process can run on any platform.

We've built an NSIS based installer and auto-updater for Windows.  On the mac the updater pulls down a zip and moves it over the current app.  We have no packaging or installer for linux yet :)

The jakefile creates the app.nw directory and then creates the platform specific packages.  When we build on the mac we can also create the DMG file directly.

We're not quite ready to share what we have but as soon as I come up for air we'll try to open source the interesting parts.

Michael


--

Steffen

unread,
Aug 13, 2013, 2:21:28 PM8/13/13
to node-...@googlegroups.com
Hey Michael,

I'm using grunt to watch my sass files and trace and minify my js files with require js. So I thought lets stay with the tools you know :)
Is there a reason you gave up on grunt ? Do you mind my asking why?

Having a dmg builder is a great idea! It shouldn't be that hard to implement this into my grunt workflow (http://stackoverflow.com/questions/367751/creating-a-dmg)

I'm not familiar with NSIS - is there a good example on how to build an installer via the cli? Can you build a NSIS installer on mac (for windows) ?

Steffen

Steffen

unread,
Aug 13, 2013, 2:47:54 PM8/13/13
to node-...@googlegroups.com
Also Michael how do you handle app icons in Windows?

Michael Winser

unread,
Aug 13, 2013, 3:17:46 PM8/13/13
to node-...@googlegroups.com
App icons turned out to be easy once we had a windows installer.

Before we had the windows installer we had a separate copy of nw.exe and used rcedit.exe to set the icon on that.  We checked that nw.exe binary into the project and then built the rest normally.

Now that we have an installer we can explicitly set the icon for the shortcut and since we can already set the app icon via the nw.GUI methods we no longer need to modify the nw.exe binary at all.

I hope this helps,

Michael

Michael Winser

unread,
Aug 13, 2013, 6:11:15 PM8/13/13
to node-...@googlegroups.com
I think that grunt has very nice built-in support for scenarios like sass and minification where the same operation can be applied to all (or almost all) files of a certain type (e.g. js and scss).  So if your need is "do operation to all somethings" then Grunt works great.

We actually started with Grunt.  As you say, go with what you know.

Where things get harder is when you have multiple targets and non trivial dependency graphs.  We have a compilation / build process involving multiple targets like mac, win32 and linux.  With Grunt the logic for each platform was spread across the Grunt tasks to the point where it was almost impossible to maintain.  With Jake I can more clearly represent the dependency graph for each target.  I can have variations of targets that depend on common pieces.

The makensis command is available as a package on linux (apt-get install makensis) and on the mac (brew install makensis)

Michael

Steffen

unread,
Aug 14, 2013, 3:35:17 AM8/14/13
to node-...@googlegroups.com
Thanks for your insighs. So far I did not really have any external dependencies. I think Grunt actually also works quite well for a subset of files since it has support for isaacs node-glob (https://github.com/isaacs/node-glob) - thats the src parameter in the grunt-plugin

But to be honest, you have to put a fair amount of work in your build process, if you want to hand of a good product to your users. 

Would be nice if you could share your jake file since there isn't really a standardized way to package apps and I think this would be helpful for a lot o people

Alexander Casanova

unread,
Aug 13, 2013, 1:48:07 PM8/13/13
to node-...@googlegroups.com
Awesome. Can't wait to try it out later.
Thanks
--
You received this message because you are subscribed to a topic in the Google Groups "node-webkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-webkit/P_NkOs1N0CU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-webkit...@googlegroups.com.

Anthony Ettinger

unread,
Aug 18, 2013, 12:24:27 AM8/18/13
to node-...@googlegroups.com
https://github.com/steffen/grunt-node-webkit-builder

I didn't think the package was available, I get a 404.


--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Benjamin Dobler

unread,
Aug 18, 2013, 6:47:01 AM8/18/13
to node-...@googlegroups.com
The link on the npmjs site is wrong. This is the correct one: https://github.com/mllrsohn/grunt-node-webkit-builder

Alex Casanova

unread,
Aug 20, 2013, 8:57:55 AM8/20/13
to node-...@googlegroups.com, benjami...@googlemail.com
I tried to use the builder for the latest 0.7.1 and received the following.

Fatal error: ENOENT, no such file or directory '/Users/acasanova/projects/personal/cassbeatspro/webkitbuilds/0.7.1/src/mac/node-webkit.app/Contents/Info.plist'

Steffen Müller

unread,
Aug 20, 2013, 9:43:39 AM8/20/13
to node-...@googlegroups.com, benjami...@googlemail.com

Thanks for the hint. There was a small bug in the unzip process. It's fixed and published to npm @ 0.1.3


Steffen

You received this message because you are subscribed to a topic in the Google Groups "node-webkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-webkit/P_NkOs1N0CU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-webkit...@googlegroups.com.

Alex Casanova

unread,
Aug 20, 2013, 11:34:00 AM8/20/13
to node-...@googlegroups.com, benjami...@googlemail.com
Thanks Steffen,
I have a nw.icns file in my app root folder. But each time I build for mac It doesn't use the nw.icns file I already have. Is that the intended function to use the nw.icns file that is in the root of the app folder?

Steffen Müller

unread,
Aug 20, 2013, 12:01:09 PM8/20/13
to node-...@googlegroups.com, benjami...@googlemail.com

By default the build process takes everything that is in the src folder, packs it and merges it the win/mac file.

I've read today that for mac it could just copy everything into node-webkit.app/Contents/Resources/ without zipping it.


You could make a pull request for that. Otherwise just replace the nw.icns in node-webkit.app/Contents/Resources/nw.icns

Marc Torruella

unread,
Sep 15, 2013, 5:46:08 AM9/15/13
to node-...@googlegroups.com
Hi all,
Sorry to bother you with basic questions... but i would appreciate a speed up on my learning process :-).

I have done some test with yeoman already and have builded my project with grunt, but now i wanted to use your node-webkit grunt tool with no success. I already read the grunt starting guide, but i'm quite a slow learner sometimes and can't figure out what i'm doing wrong.

My project consist of a "app" folder where i have all the code with the node-webkit package.json file, a "dist" empty folder to store de binnaries, and a Gruntfile.js with a modified version of your sample file:

module.exports = function(grunt) {

  grunt.initConfig({
  nodewebkit: {
    options: {
        webkit_src: './dist', // Where the build version of my node-webkit app is saved
        mac: true, // We want to build it for mac
        win: true, // We want to build it for win
        linux32: false, // We don't need linux32
        linux64: false // We don't need linux64
    },
    src: ['./app/**/*'] // Your node-wekit app
},
})

  grunt.loadNpmTasks('grunt-node-webkit-builder');
};

When i try to run "grunt" command on the root of my project i get the following:

Inline image 1

So i guess i'm doing something terribly wrong :p
if i try "grunt nodewebkit" i get the same error just that the task not found is nodewebkit :_)

i have already run "npm install grunt-node-webkit-builder --save-dev" and got all the node modules installed... what else i'm missing? the package.json? on your website you say to use js or json like if it wasn't necessary, is it? :-)

Thank you in advance for your help!

Marc


Sin título.jpg

Anatoly Pashin

unread,
Sep 15, 2013, 7:02:39 AM9/15/13
to node-...@googlegroups.com
Looks like this is the problem:

2013/9/15 Marc Torruella <rollwh...@gmail.com>

src: ['./app/**/*'] // Your node-wekit app

Please try to remove this line because it's default (https://github.com/mllrsohn/grunt-node-webkit-builder/blob/master/tasks/node_webkit_builder.js#L17) or remove array defining (leave just string).
Looks like example code has bug, because code processing `src' attr don't assume you pass array (https://github.com/mllrsohn/grunt-node-webkit-builder/blob/master/tasks/node_webkit_builder.js#L48


--
Пашин Анатолий,
эникейщик.

Marc Torruella

unread,
Sep 15, 2013, 7:46:52 AM9/15/13
to node-...@googlegroups.com
thank you, now i get : "Arguments to path.resolve must be strings"... all my paths are strings now, so i guess i something inside grunt-node-webkit-builder? maybe somethings changed in grunt's latest version? 

most probably i'm doing something wrong...


--

Marc Torruella

unread,
Sep 15, 2013, 8:11:34 AM9/15/13
to node-...@googlegroups.com
Ok, i now used the gruntfile on the package and it seems to work, just ignore the example in the docs :-)

But... instead of running my app it shows me the js code of a node module i have inside my app... looks like the grunt searches for a package.json file and uses the first it gets even if its not on the projects root folder...
Reply all
Reply to author
Forward
0 new messages