Skip to content

Commit

Permalink
[Webpack/Moment] Include used locales only
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Jun 15, 2017
1 parent bf48560 commit 0726e00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/AppBundle/Form/Type/DateTimePickerType.php
Expand Up @@ -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(), '_', '-'));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion webpack.config.js
Expand Up @@ -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;

0 comments on commit 0726e00

Please sign in to comment.