Skip to content

Commit 0726e00

Browse files
committed
[Webpack/Moment] Include used locales only
1 parent bf48560 commit 0726e00

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/AppBundle/Form/Type/DateTimePickerType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(MomentFormatConverter $converter)
4141
public function buildView(FormView $view, FormInterface $form, array $options)
4242
{
4343
$view->vars['attr']['data-date-format'] = $this->formatConverter->convert($options['format']);
44-
$view->vars['attr']['data-date-locale'] = \Locale::getDefault();
44+
$view->vars['attr']['data-date-locale'] = mb_strtolower(strtr(\Locale::getDefault(), '_', '-'));
4545
}
4646

4747
/**

webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Encore
2323

2424
var config = Encore.getWebpackConfig();
2525

26-
config.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/));
26+
config.plugins.push(new webpack.ContextReplacementPlugin(
27+
/moment[\/\\]locale$/,
28+
/en|fr|de|es|cs|nl|ru|uk|ro|pt-br|pl|it|ja|id|ca|sl|hr|zh-cn/
29+
));
2730

2831
module.exports = config;

0 commit comments

Comments
 (0)