babel-plugin-date-fns-next
v1.0.0
Published
> :warning: The current master is for v2 pre-release version of date-fns. [See the plugin of v1 version](https://github.com/date-fns/babel-plugin-date-fns/tree/v1).
Downloads
2
Readme
babel-plugin-date-fns
:warning: The current master is for v2 pre-release version of date-fns. See the plugin of v1 version.
Install
$ npm i --save date-fns
$ npm i --save-dev babel-plugin-date-fns
Example
Transforms
import { distanceInWordsToNow, differenceInYears, format } from 'date-fns';
roughly to
import distanceInWordsToNow from 'date-fns/distanceInWordsToNow';
import differenceInYears from 'date-fns/differenceInYears';
import format from 'date-fns/format';
Usage
.babelrc
{
"plugins": ["date-fns"],
"presets": ["es2015"]
}
Webpack 2
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
presets: ['es2015'],
plugins: ['date-fns'],
},
}],
}
Thanks
Heavily inspired by babel-plugin-lodash and babel-plugin-recharts.