Webpack Globalize fails to build when configured in production mode: without formatting or parsers

I am working on a React / Webpack / Globalize application. In development mode, everything is fine (although Globalize insists on compiling all the locales, not on what I chose, but on a different question the other day).
However, when I set production: true in my webpack configuration, I get the following error when starting npm run build

 > webpack --config webpack.prod.config.js /opt/app/ui/node_modules/globalize-webpack-plugin/GlobalizeCompilerHelper.js:72 throw e; ^ Error: No formatters or parsers has been provided 

I was impressed that the globalize webpack plugin is designed to handle precompilation. Any idea why I see this error? When I set production: false , everything compiles fine.

My plugin setup:

 new GlobalizePlugin({ production: true, developmentLocale: "en", supportedLocales: [ "en"], output: "i18n/[locale].[hash].js" }), 

When the file changes and rebuilds the webpack dev servers, I get a lot of messages indicating that the locales are repeating, which I do not use:

 [461] ./~/cldr-data/main/es-PY/dateFields.json 15 kB {0} [optional] [462] ./~/cldr-data/main/es-SV/dateFields.json 15 kB {0} [optional] [463] ./~/cldr-data/main/es-US/dateFields.json 15 kB {0} [optional] [464] ./~/cldr-data/main/es-UY/dateFields.json 15 kB {0} [optional] [465] ./~/cldr-data/main/es-VE/dateFields.json 15 kB {0} [optional] [466] ./~/cldr-data/main/es/dateFields.json 15 kB {0} [optional] 

Nothing I try seems to get this problem.
Thanks

+7
npm webpack javascript-globalize jquery-globalize
source share
1 answer

Be that as it may, the messages key is not "optional", but is actually necessary. Moreover, somewhere you need to "simply" (due to the lack of a better word) format messages by calling Globalize.formatMessage("somekey") (where there is some key in your lang file). All this is required if production set to true .

Also, if you set production to true, the output path must match the existing path in the source tree. If, for example, your code is embedded in /assets , the output path should be assets/i18n/[locale].[hash].js . Otherwise, the i18n directory will not be created during assembly.

All this comes from a discussion in the github repository:

https://github.com/rxaviers/globalize-webpack-plugin/issues/10

+2
source share

All Articles