# grunt-usemin2

> An alternative to grunt-usemin.

Latest version **0.0.6** (published 2014-08-15) · 0 weekly downloads

## Install

```sh
npm install grunt-usemin2
pnpm add grunt-usemin2
yarn add grunt-usemin2
bun add grunt-usemin2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2014-08-15 |
| First published | 2013-07-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | even |
| Keywords | grunt, usemin, minify, css, js, uglify |

## Links

- npm: https://www.npmjs.com/package/grunt-usemin2
- Repository: https://bitbucket.org/qraynaud/grunt-usemin2
- Issues: https://bitbucket.org/qraynaud/grunt-usemin2/issues
- npm.io page: https://npm.io/package/grunt-usemin2

## Dependencies (1)

- [deferred](https://npm.io/package/deferred.md) ^0.7.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.6 (latest) — 2014-08-15
- 0.0.5 — 2014-04-21
- 0.0.4 — 2014-04-21
- 0.0.3 — 2013-08-03
- 0.0.2 — 2013-07-30
- 0.0.1 — 2013-07-29

## README

# grunt-usemin2
An alternative to grunt-usemin

## Usage

### Configuration

```javascript
{
  options: {
    // If provided, then set all path in html files relative to this directory
    baseDir: "baseDir/",

    // Same thing as baseDir but forces path to be absolute to this directory
    absoluteBaseDir: "baseDir/",

    // Task(s) to execute to process the css
    cssmin: 'cssmin',

    // Task(s) to execute to process the js
    jsmin: 'uglify'
  },

  // This should contain a reference to all HTML files that usemin2
  // needs to process
  html: 'src/*.html',

  // This section contain everything about css files processing
  css: {
    // You can create as much section as you want with
    // any name you want to use
    section_name: {
      // Each section should define a destination that point to the file
      // that will be created if the minification process is executed
      dest: "dest/css/section_name.min.css",

      // Files that needs to be processed for this section
      files: [{
        // Same as usual
        cwd: "src",
        // List of src (can be an array), each can be expanded,
        // you can also use a special "__min__" markup to select
        // thje correct file depending on the running process
        src: ["css/*.css", "externals/css/*__min__.css"]
        // Destination of the files when no minification process
        // occurs
        dest: "dest/"
      } /* , ... */]
    }/* , ... */
  },

  // Same as css but for js files
  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 :

```html
<!-- usemin2:css:section_name -->
<!-- usemin2:js:section_name -->
```

### 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](http://en.wikipedia.org/wiki/MIT_License)

---
_Source: https://npm.io/package/grunt-usemin2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
