momentjs guide and fix webpack babel loader
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# Moment.js
|
||||
|
||||
This guide shows you how to install and use Moment.js, a popular date library in ToonBoom Harmony.
|
||||
|
||||
Install it from NPM and create a new script file:
|
||||
|
||||
```sh
|
||||
❯ npm install moment
|
||||
❯ touch ./src/scripts/moment.ts
|
||||
```
|
||||
|
||||
Use ES modules to import the library:
|
||||
|
||||
```ts
|
||||
// src/scripts/moment.ts
|
||||
import moment from "moment";
|
||||
|
||||
MessageLog.trace(moment().locale("es").format("LLLL"));
|
||||
```
|
||||
|
||||
Build it:
|
||||
|
||||
```sh
|
||||
❯ npm run build
|
||||
```
|
||||
|
||||
Then run `dist/moment.js` in Harmony:
|
||||
|
||||
```txt
|
||||
martes, 18 de noviembre de 2025 12:23
|
||||
```
|
||||
Reference in New Issue
Block a user