<commit_before># grunt-usemin [![Build Status](https://secure.travis-ci.org/yeoman/grunt-usemin.svg?branch=master)](http://travis-ci.org/yeoman/grunt-usemin)

> Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views).

Watch out, this task is designed for Grunt 0.4 and upwards.

## Getting Started
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

```shell
npm install grunt-usemin --save-dev
```

[grunt]: http://gruntjs.com/
[Getting Started]: http://gruntjs.com/getting-started

## Tasks

`usemin` exports 2 different tasks:
* `useminPrepare` prepares the configuration to transform specific construction (blocks) in the scrutinized file into a single line, targeting an optimized version of the files (e.g concatenated, uglifyjs-ed ...)
* `usemin` replaces the blocks by the file they reference, and replaces all references to assets by their revisioned version if it is found on the disk. This target modifies the files it is working on.

In addition, `useminPrepare` dynamically generates the configuration for `concat`, `uglify`, and `cssmin`.
**Important**: _you still need to manually manage these dependencies and call each task_.

Usually, `useminPrepare` is launched first, then the steps of the transformation flow (e.g. `concat`, `uglify`, and `cssmin`), and then, in the end `usemin` is launched. For example:

```js
// simple build task
grunt.registerTask('build', [
  'useminPrepare',
  'concat',
  'cssmin',
  'uglify',
  'rev',
  'usemin'
]);
```

## The useminPrepare task

`useminPrepare` task updates the grunt configuration to apply a configured transformation flow to tagged files (i.e. blocks).
By default the transformation flow is composed of `concat` and `uglifyjs` for JS files, but it can be configured.

### Blocks
Blocks are expressed as:

```html
<!-- build:<type>(alternate search path) <path> -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->
```

* **type**: either `js` or `css`
* **alternate search path**: (optional) By default the input files are relative to the treated file. Alternate search path allows one to change that
* **path**: the file path of the optimized file, the target output

An example of this in completed form can be seen below:

```html
<!-- build:js js/app.js -->
<script src="js/app.js"></script>
<script src="js/controllers/thing-controller.js"></script>
<script src="js/models/thing-model.js"></script>
<script src="js/views/thing-view.js"></script>
<!-- endbuild -->
```

### Transformation flow

The transformation flow is made of sequential steps: each of the steps transform the file, and useminPrepare will modify the configuration in order for the described steps to be correctly performed.

By default the flow is: `concat -> uglifyjs`.<commit_msg>Document "ignored" blocks<commit_after># grunt-usemin [![Build Status](https://secure.travis-ci.org/yeoman/grunt-usemin.svg?branch=master)](http://travis-ci.org/yeoman/grunt-usemin)

> Replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views).

Watch out, this task is designed for Grunt 0.4 and upwards.

## Getting Started
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:

```shell
npm install grunt-usemin --save-dev
```

[grunt]: http://gruntjs.com/
[Getting Started]: http://gruntjs.com/getting-started

## Tasks

`usemin` exports 2 different tasks:
* `useminPrepare` prepares the configuration to transform specific construction (blocks) in the scrutinized file into a single line, targeting an optimized version of the files (e.g concatenated, uglifyjs-ed ...)
* `usemin` replaces the blocks by the file they reference, and replaces all references to assets by their revisioned version if it is found on the disk. This target modifies the files it is working on.

In addition, `useminPrepare` dynamically generates the configuration for `concat`, `uglify`, and `cssmin`.
**Important**: _you still need to manually manage these dependencies and call each task_.

Usually, `useminPrepare` is launched first, then the steps of the transformation flow (e.g. `concat`, `uglify`, and `cssmin`), and then, in the end `usemin` is launched. For example:

```js
// simple build task
grunt.registerTask('build', [
  'useminPrepare',
  'concat',
  'cssmin',
  'uglify',
  'rev',
  'usemin'
]);
```

## The useminPrepare task

`useminPrepare` task updates the grunt configuration to apply a configured transformation flow to tagged files (i.e. blocks).
By default the transformation flow is composed of `concat` and `uglifyjs` for JS files, but it can be configured.

### Blocks
Blocks are expressed as:

```html
<!-- build:<type>(alternate search path) <path> -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->
```

* **type**: either `js` or `css`
 * If another type, the block will be ignored.  Useful for "development only" blocks that won't appear in your build
* **alternate search path**: (optional) By default the input files are relative to the treated file. Alternate search path allows one to change that
* **path**: the file path of the optimized file, the target output

An example of this in completed form can be seen below:

```html
<!-- build:js js/app.js -->
<script src="js/app.js"></script>
<script src="js/controllers/thing-controller.js"></script>
<script src="js/models/thing-model.js"></script>
<script src="js/views/thing-view.js"></script>
<!-- endbuild -->
```

### Transformation flow

The transformation flow is made of sequential steps: each of the steps transform the file, and useminPrepare will modify the configuration in order for the described steps to be correctly performed.

By default the flow is: `concat -> uglifyjs`.
{'fraction_non_alphanumeric': 0.11499106707812246, 'fraction_numerical': 0.0009745005684586649, 'mean_word_length': 4.588021778584392, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1931504', 'n_tokens_mistral': 1806, 'n_tokens_neox': 1735, 'n_words': 774}