Skip to content

Instantly share code, notes, and snippets.

@jasonkarns
Last active December 20, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonkarns/6073507 to your computer and use it in GitHub Desktop.
Save jasonkarns/6073507 to your computer and use it in GitHub Desktop.
Support arbitrary static files in Lineman with the grunt-contrib-copy task

Support arbitrary static files in Lineman with the grunt-contrib-copy task

  1. add grunt-contrib-copy task to package.json package.json line 2
  2. configure lineman to load the task via npm config/application.coffee line 4
  3. configure lineman to run the copy task as part of its run/build process config/application.coffee lines 9-11
  4. configure the copy task itself config/application.coffee lines 14-18

With this configuration, any file or directory (recursively) in static/ will be copied over as a static asset. (directory structure is preserved.) For example, given:

static/
  favicon.ico
  js/
    html5shim.js

Then lineman build (with latest lineman, and default setup) will create:

dist/
  css/
    app.css
  favicon.ico
  index.html
  js/
    app.js
    html5shim.js

Warning: If there are any name conflicts between files in 'static' and the normal lineman build assets, the static files will overwrite the others (since the copy task is run last).

module.exports = require(process.env['LINEMAN_MAIN']).config.extend "application",
# tell lineman to load the grunt-contrib-copy task via npm
loadNpmTasks: 'grunt-contrib-copy'
# tell lineman to run the copy tasks as part of its build process
# run 'dev' target for both run and build phases
# run 'dist' target during build phase
appendTasks:
common: "copy:dev"
dist: "copy:dist"
# configure the copy task
copy:
dev:
files: [ expand: true, cwd: 'static', src: '**', dest: 'generated' ]
dist:
files: [ expand: true, cwd: 'static', src: '**', dest: 'dist' ]
"dependencies": {
"grunt-contrib-copy": "~0.4.1"
}
@deftOfCenter
Copy link

And just as a quick reminder, make sure to npm install!!!!!

npm install

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