Skip to content

Commit

Permalink
minor #592 [Webpack/Moment] Include all moment locales (yceruto, javi…
Browse files Browse the repository at this point in the history
…ereguiluz)

This PR was merged into the master branch.

Discussion
----------

[Webpack/Moment] Include all moment locales

This resolves #591 if someone else can confirm the same error.

The `admin.js` file size in production increases to `227k` (from `178k`)

The locale list comes from `config.yml`:
```yaml
parameters:
    # This parameter defines the codes of the locales (languages) enabled in the application
    app_locales: en|fr|de|es|cs|nl|ru|uk|ro|pt_BR|pl|it|ja|id|ca|sl|hr|zh_CN
```

Commits
-------

1818ab4 Removed an unneeded variable
774a4b8 [Webpack/Moment] Include all moment locales
0726e00 [Webpack/Moment] Include used locales only
  • Loading branch information
javiereguiluz committed Jun 19, 2017
2 parents bf48560 + 1818ab4 commit fe5a987
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 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
7 changes: 1 addition & 6 deletions webpack.config.js
@@ -1,5 +1,4 @@
var Encore = require('@symfony/webpack-encore');
var webpack = require('webpack');

Encore
.setOutputPath('web/build/')
Expand All @@ -21,8 +20,4 @@ Encore
.addStyleEntry('css/admin', ['./app/Resources/assets/scss/admin.scss'])
;

var config = Encore.getWebpackConfig();

config.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/));

module.exports = config;
module.exports = Encore.getWebpackConfig();

0 comments on commit fe5a987

Please sign in to comment.