Search code examples
reactjscharacter-encodingreact-intl

React webpack bundle not utf-8


I am building a react webapp using among other things webpack and react-intl. My app is supposed to be in swedish and english. When i build the web app in development mode it works fine.

But when I build the app and run it as a static web site I run into problems with the char encoding: Ö becomes Ö and so on.

Could this be an error in the loader? Or where should I start the trouble shooting?

I load the translation files like this:

import { IntlProvider, addLocaleData } from 'react-intl';
import formatTranslations from 'utils/formaters/translations-formater';
import en from 'react-intl/locale-data/en';
import sv from 'react-intl/locale-data/sv';
addLocaleData([...en, ...sv]);

import svStrings from 'locales/sv';
import enStrings from 'locales/en';

const strings = { 
  sv: formatTranslations(svStrings),
  en: formatTranslations(enStrings)
};

Solution

  • I solved the issue by adding this to my html:

    <meta charset="UTF-8">
    

    I do not know why it is not needed for the when running the app in development.