Skip to content

Instantly share code, notes, and snippets.

@mreis1
Last active January 24, 2017 22:32
Show Gist options
  • Save mreis1/61086ca6ad16aa41c11b0c507e6c77f4 to your computer and use it in GitHub Desktop.
Save mreis1/61086ca6ad16aa41c11b0c507e6c77f4 to your computer and use it in GitHub Desktop.
grunt-usemin tips and tricks

#grunt-usemin tips and tricks

-[Root]
...
--package.json
--gruntfile.js
--app
----index.html
----main.js
--bower_components
----some/lib.js

Hint 1

First of all, all build blocks are relative to the html file by default. (Example <!-- build:js output.js -->) All files referenced later will be search inside app which is the directory of our index.html

Hint 2

The (.) must be used if your referenced files are relative to the root of your project. In this case the dot means the location of our gruntfile.js <!-- build:js(.) output.js -->

Hint 3

The (../) must be used if your referenced files are above the context of our current html file <!-- build:js(../) output.js -->

Hint 4

The (app) must be used if your referenced files are relative to the app which is a child from our root directory <!-- build:js(app) output.js -->

Hint 5

gulp-usemin has support for multi base directory search but grunt-usemin does not support this! <!-- build:js({app, app2}) output.js --> (gulp syntax) or <!-- build:js(app, app2) output.js --> (grunt syntax) will not work! The last one will just find files in the first folder and all other will be ignored so the build will be incomplete.

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