Permalink
Browse files

refactor(date): replace moment with date-fns

  • Loading branch information...
axe312ger committed Aug 16, 2017
1 parent c689299 commit ded7fe9259934aa73cf5b8cc939c55357e1ce2b8
Showing with 8 additions and 6 deletions.
  1. +2 −1 .babelrc
  2. +2 −1 package.json
  3. +3 −2 src/app/modules/assets/components/Assets.js
  4. +1 −2 webpack.config.js
View
@@ -2,7 +2,8 @@
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
"transform-async-to-generator"
"transform-async-to-generator",
"date-fns"
],
"presets": [
"preact",
View
@@ -25,6 +25,7 @@
"babel-core": "^6.24.0",
"babel-eslint": "^7.2.1",
"babel-loader": "^7.1.1",
"babel-plugin-date-fns": "^0.1.0",
"babel-plugin-transform-async-to-generator": "^6.22.0",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
@@ -68,8 +69,8 @@
},
"dependencies": {
"contentful-management": "^4.0.1",
"date-fns": "^1.28.5",
"history": "^4.6.3",
"moment": "^2.18.1",
"normalize.css": "^7.0.0",
"preact": "^8.2.1",
"preact-compat": "^3.14.3",
@@ -1,6 +1,6 @@
import { h, Component } from 'preact'
import moment from 'moment'
import { distanceInWordsToNow } from 'date-fns'
import proptypes from 'proptypes'
import Dropzone from 'react-dropzone'
@@ -29,7 +29,8 @@ export default class Assets extends Component {
const localeTitle = Object.keys(title)[0]
const localizedTitle = title[localeTitle]
const ext = /\.(.*)$/.exec(file[localeFile].fileName)[1]
const created = `created ${moment(createdAt).fromNow()}`
const formattedDate = distanceInWordsToNow(createdAt, { includeSeconds: true })
const created = `created ${formattedDate} ago`
let preview = (
<div className={styles.fileIcon}>
View
@@ -131,8 +131,7 @@ const webpackConfig = {
new Webpack.DefinePlugin({
APP_CONFIG: JSON.stringify(config)
}),
new ExtractTextPlugin('styles.css'),
new Webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(en|de)(?!-)/)
new ExtractTextPlugin('styles.css')
]
}

0 comments on commit ded7fe9

Please sign in to comment.