grunt-usemin2
An alternative to grunt-usemin
Usage
Configuration
{
options: {
baseDir: "baseDir/",
absoluteBaseDir: "baseDir/",
cssmin: 'cssmin',
jsmin: 'uglify'
},
html: 'src/*.html',
css: {
section_name: {
dest: "dest/css/section_name.min.css",
files: [{
cwd: "src",
src: ["css/*.css", "externals/css/*__min__.css"]
dest: "dest/"
} ]
}
},
js: {
}
}
Options
baseDir
: not set by default, set all path in html files relative to this directory.absoluteBaseDir
: same as baseDir
but forces path to be absolute from this point
(starting with a /).cssmin
: defaults to 'cssmin'
, tasks to execute to minify CSS files. Also
accepts an array of tasks like ['cssmin1', 'cssmin2']
. In this case, it supposes
that the first task is able to produce a single file from numerous inputs. If it
does not, use 'concat' first like in: ['concat', 'taskonsinglefile', 'cssmin']
.jsmin
: same as cssmin
but for js minification process, defaults to 'uglify'
.
HTML files
Just add simple comments to your HTML file that will be replaced by
the correct include(s) depending on the process :
Invokation
Right now, by default grunt-usemin2 assume it is in dev mode
. It means that
it will publish each files listed in src sections to its corresponding
destination and then replace sections in HTML files by a list of all moved files.
To activate the minification process, you need to be in release mode
. To do so,
you have to pass a release
argument to the task just like that :
grunt usemin2:release
Any argument value other than release
is ignored thus making the task behave
as if in dev mode
.
When the minification process is used, each task of the process is executed resulting
in a single file per section. This is the single file that will be included in the
HTML file where the section is referenced.
License
MIT License