Create a gist now

Instantly share code, notes, and snippets.

@balupton /README.md
Last active Dec 10, 2015

Embed
What would you like to do?
DocPad: Bundle your scripts with Browserify

DocPad: Bundle your scripts with Browserify

The following will bundle your script assets with browserify each time a generation write completes. The bundled file will be located at my-website/out/scripts.js if you are using all the default configuration for your paths.

Installation

  1. Install Dependencies

    npm install --save browserify safeps
  2. Add the following to your docpad configuration file

    # Write After
    # Used to bundle the editor
    writeAfter: (opts,next) ->
    	# Prepare
    	{rootPath, outPath} = @docpad.getConfig()
    
    	# Bundle the scripts the editor uses together
    	command = """
    		#{rootPath}/node_modules/.bin/browserify
    		#{outPath}/vendor/jquery.js
    		#{outPath}/scripts/script.js
    		-o #{outPath}/scripts.js
    		""".replace(/\n/g,' ')
    
    	# Execute
    	require('safeps').exec(command, {cwd:rootPath, output:true}, next)
    
    	# Chain
    	@
@jpillora

This comment has been minimized.

Show comment
Hide comment
@jpillora

jpillora Mar 8, 2013

Also need to: balUtil = require "bal-util" at the top

jpillora commented Mar 8, 2013

Also need to: balUtil = require "bal-util" at the top

@digitaldesigndj

This comment has been minimized.

Show comment
Hide comment
@digitaldesigndj

digitaldesigndj Jul 26, 2013

I have created a simple docpad plugin that will do simple browserify rendering as a plugin, all you have to do is add .browserify or .b as an extension.

https://github.com/digitaldesigndj/docpad-plugin-browserify

It's working, but still a work in progress. So far I have mostly used it with https://npmjs.org/package/jquery-browserify

digitaldesigndj commented Jul 26, 2013

I have created a simple docpad plugin that will do simple browserify rendering as a plugin, all you have to do is add .browserify or .b as an extension.

https://github.com/digitaldesigndj/docpad-plugin-browserify

It's working, but still a work in progress. So far I have mostly used it with https://npmjs.org/package/jquery-browserify

@digitaldesigndj

This comment has been minimized.

Show comment
Hide comment
@digitaldesigndj

digitaldesigndj Jul 30, 2013

Hmm, it seems that this gist does not work with balUtil 2.3.x, however it does work with balUtil 2.0.x

digitaldesigndj commented Jul 30, 2013

Hmm, it seems that this gist does not work with balUtil 2.3.x, however it does work with balUtil 2.0.x

@balupton

This comment has been minimized.

Show comment
Hide comment
Owner

balupton commented Nov 29, 2013

@digitaldesigndj fixed :)

@giodamelio

This comment has been minimized.

Show comment
Hide comment
@giodamelio

giodamelio Dec 10, 2013

As someone who had never done much with docpad config before, it wasn't very clear that this should all be a child of events:, you might want to add that.

giodamelio commented Dec 10, 2013

As someone who had never done much with docpad config before, it wasn't very clear that this should all be a child of events:, you might want to add that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment