esbuild-plugin-filelastmodified
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "esbuild-plugin-filelastmodified", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"repository": "https://github.com/g45t345rt/esbuild-plugin-filelastmodified", | ||
@@ -16,9 +16,9 @@ "description": "A esbuild plugin to replace __fileLastModified__ with the actual time the file has been modified.", | ||
"devDependencies": { | ||
"@types/node": "^14.14.35", | ||
"@types/node": "^14.14.37", | ||
"chai": "^4.3.4", | ||
"cross-env": "^7.0.3", | ||
"esbuild": "^0.9.6", | ||
"esbuild": "^0.11.2", | ||
"mocha": "^8.3.2", | ||
"typescript": "^4.2.3" | ||
} | ||
} | ||
} |
# esbuild-plugin-filelastmodified | ||
A esbuild plugin to replace `__fileLastModified__` with the actual time the file has been modified. | ||
A esbuild plugin to replace `__fileLastModified__` with the date the file was last modified. | ||
## Why | ||
Avoid having to manually change the the last time the file was modified everytime you make an edit. | ||
Avoid having to manually hardcode the date and change it every time you make an edit on your website pages. It's very usefull for displaying -> `Modified date: 2021-03-31` at the end of web pages. | ||
@@ -14,3 +14,3 @@ ## Install | ||
## Usage | ||
## Apply plugin to esbuild | ||
@@ -29,2 +29,19 @@ ```js | ||
## How I would actually use it in React | ||
```js | ||
// Home.js | ||
import React from 'react' | ||
import dayjs from 'dayjs' | ||
import localizedFormat from 'dayjs/plugin/localizedFormat' | ||
dayjs.extend(localizedFormat) | ||
const lastModified = __fileLastModified__ // <-- this gets replaced by the plugin as unix date time | ||
export default () => { | ||
return <div>{dayjs(lastModified).format('LLL')}</div> | ||
} | ||
``` | ||
### Conversion | ||
#### Before | ||
@@ -31,0 +48,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6360
63