@denkristoffer/babel-plugin-date-fns
v0.2.1
Published
## Install
Downloads
6
Maintainers
Readme
babel-plugin-date-fns
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.