Skip to content

Commit

Permalink
Promote better the usage options ❤️
Browse files Browse the repository at this point in the history
  • Loading branch information
pirelenito committed May 11, 2017
1 parent 8da3bc9 commit 9ebcf08
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,45 @@ And (optionally [when branch is enabled](#branch-false)) a `BRANCH` such as:
master
```

## Path Substitutions

It is also possible to use [path substituitions](http://webpack.github.io/docs/configuration.html#output-filename) on build to get the revision, version or branch as part of output paths.

- `[git-revision-version]`
- `[git-revision-hash]`
- `[git-revision-branch]` (only [when branch is enabled](#branch-false))

Example:

```javascript
module.exports = {
output: {
publicPath: 'http://my-fancy-cdn.com/[git-revision-version]/',
filename: '[name]-[git-revision-hash].js'
}
}
```

## Plugin API

The `VERSION`, `COMMITHASH` and `BRANCH` are also exposed through a public API.

Example using the [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin):

```javascript
var gitRevisionPlugin = new GitRevisionPlugin()

module.exports = {
plugins: [
new DefinePlugin({
'VERSION': JSON.stringify(gitRevisionPlugin.version()),
'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
'BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
})
]
}
```

## Configuration

The plugin requires no configuration by default, but it is possible to configure it to support custom git workflows.
Expand Down Expand Up @@ -129,42 +168,3 @@ module.exports = {
]
}
```

## Path Substitutions

It is also possible to use two [path substituitions](http://webpack.github.io/docs/configuration.html#output-filename) on build to get either the revision or version as part of output paths.

- `[git-revision-version]`
- `[git-revision-hash]`
- `[git-revision-branch]` (only [when branch is enabled](#branch-false))

Example:

```javascript
module.exports = {
output: {
publicPath: 'http://my-fancy-cdn.com/[git-revision-version]/',
filename: '[name]-[git-revision-hash].js'
}
}
```

## Plugin API

The `VERSION`, `COMMITHASH` and `BRANCH` are also exposed through a public API.

Example using the [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin):

```javascript
var gitRevisionPlugin = new GitRevisionPlugin()

module.exports = {
plugins: [
new DefinePlugin({
'VERSION': JSON.stringify(gitRevisionPlugin.version()),
'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
'BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
})
]
}
```

0 comments on commit 9ebcf08

Please sign in to comment.