From 0726e0091ff93fbaec76005638c6a4d1ea14d61b Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 15 Jun 2017 14:31:30 -0400 Subject: [PATCH] [Webpack/Moment] Include used locales only --- src/AppBundle/Form/Type/DateTimePickerType.php | 2 +- webpack.config.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AppBundle/Form/Type/DateTimePickerType.php b/src/AppBundle/Form/Type/DateTimePickerType.php index d1f8d996e..1c370b40c 100644 --- a/src/AppBundle/Form/Type/DateTimePickerType.php +++ b/src/AppBundle/Form/Type/DateTimePickerType.php @@ -41,7 +41,7 @@ public function __construct(MomentFormatConverter $converter) public function buildView(FormView $view, FormInterface $form, array $options) { $view->vars['attr']['data-date-format'] = $this->formatConverter->convert($options['format']); - $view->vars['attr']['data-date-locale'] = \Locale::getDefault(); + $view->vars['attr']['data-date-locale'] = mb_strtolower(strtr(\Locale::getDefault(), '_', '-')); } /** diff --git a/webpack.config.js b/webpack.config.js index 801b8a0d6..95c2e3aa8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -23,6 +23,9 @@ Encore var config = Encore.getWebpackConfig(); -config.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)); +config.plugins.push(new webpack.ContextReplacementPlugin( + /moment[\/\\]locale$/, + /en|fr|de|es|cs|nl|ru|uk|ro|pt-br|pl|it|ja|id|ca|sl|hr|zh-cn/ +)); module.exports = config;