Skip to content

Commit d8079d1

Browse files
committed
document globalOptions
`globalOptions` is useful when a babel plugin needs non-serializable options (such as functions, callbacks), thus it's worth mentioning in the README.
1 parent e9e3702 commit d8079d1

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# babel-loader
2-
[![NPM Status](https://img.shields.io/npm/v/babel-loader.svg?style=flat)](https://www.npmjs.com/package/babel-loader)
3-
[![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader)
1+
# babel-loader
2+
[![NPM Status](https://img.shields.io/npm/v/babel-loader.svg?style=flat)](https://www.npmjs.com/package/babel-loader)
3+
[![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader)
44
[![Build Status](https://ci.appveyor.com/api/projects/status/vgtpr2i5bykgyuqo/branch/master?svg=true)](https://ci.appveyor.com/project/danez/babel-loader/branch/master)
55
[![codecov](https://codecov.io/gh/babel/babel-loader/branch/master/graph/badge.svg)](https://codecov.io/gh/babel/babel-loader)
66
> Babel is a compiler for writing next generation JavaScript.
@@ -81,6 +81,23 @@ module: {
8181
}
8282
```
8383

84+
or by using global options:
85+
86+
```javascript
87+
module: {
88+
loaders: [
89+
{
90+
test: /\.js$/,
91+
exclude: /(node_modules|bower_components)/,
92+
loader: 'babel-loader'
93+
}
94+
]
95+
},
96+
babel: {
97+
presets: ['es2015']
98+
}
99+
```
100+
84101
This loader also supports the following loader-specific option:
85102

86103
* `cacheDirectory`: Default `false`. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is blank (`loader: 'babel-loader?cacheDirectory'`) or `true` (`loader: babel-loader?cacheDirectory=true`) the loader will use the default cache directory in `node_modules/.cache/babel-loader` or fallback to the default OS temporary file directory if no `node_modules` folder could be found in any root directory.

0 commit comments

Comments
 (0)