You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/react-scripts/template/README.md
+27
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
81
81
-[`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra)
82
82
-[`npm run build` silently fails](#npm-run-build-silently-fails)
83
83
-[`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)
84
+
-[Moment.js locales are missing](#momentjs-locales-are-missing)
84
85
-[Something Missing?](#something-missing)
85
86
86
87
## Updating to New Releases
@@ -1616,6 +1617,32 @@ It is reported that `npm run build` can fail on machines with no swap space, whi
1616
1617
This may be a problem with case sensitive filenames.
1617
1618
Please refer to [this section](#resolving-heroku-deployment-errors).
1618
1619
1620
+
### Moment.js locales are missing
1621
+
1622
+
If you use a [Moment.js](https://momentjs.com/), you might notice that only the English locale is available by default. This is because the locale files are large, and you probably only need a subset of [all the locales provided by Moment.js](https://momentjs.com/#multiple-locale-support).
1623
+
1624
+
To add a specific Moment.js locale to your bundle, you need to import it explicitly.<br>
1625
+
For example:
1626
+
1627
+
```js
1628
+
import moment from 'moment';
1629
+
import 'moment/locale/fr';
1630
+
```
1631
+
1632
+
If import multiple locales this way, you can later switch between them by calling `moment.locale()` with the locale name:
1633
+
1634
+
```js
1635
+
importmomentfrom'moment';
1636
+
import'moment/locale/fr';
1637
+
import'moment/locale/es';
1638
+
1639
+
// ...
1640
+
1641
+
moment.locale('fr');
1642
+
```
1643
+
1644
+
This will only work for locales that have been explicitly imported before.
1645
+
1619
1646
## Something Missing?
1620
1647
1621
1648
If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md)
0 commit comments