Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ascii Codes not Converted in Production Webpack Build #254

Open
epihel opened this issue Nov 12, 2018 · 2 comments
Open

Ascii Codes not Converted in Production Webpack Build #254

epihel opened this issue Nov 12, 2018 · 2 comments

Comments

@epihel
Copy link

epihel commented Nov 12, 2018

Using the form on http://wix.github.io/react-templates/, the HTML <p>We&#8217;re here.</p> gets converted to React.createElement('p', {}, 'We\u2019re here.') as expected.

Using webpack, react-templates, and react-templates-loader in development, the output is also as expected.

But in the webpack production build, it's converted to r.createElement("p",{},"We’re here."), which renders as <p>We’re here.</p> in Chrome.

My webpack config is { test: /\.rt$/, loader: 'react-templates-loader?modules=es6' } and I'm using the latest node (10.13.0), react (16.6.1), react-templates (0.6.3), react-templates-loader (0.6.5), and webpack (4.25.1).

@nippur72
Copy link
Contributor

It's strange because it should be the same... I can't see why production should be different from development.

Anyway I remember I had some problem parsing HTML entities (that's how they are called) I traced it back to the cheerio library (used by react-templates), but I didn't solve it completely because I later moved to a template engine of my own.

@epihel
Copy link
Author

epihel commented Nov 14, 2018

It definitely has different output. In development, it's React.createElement('p', {}, 'We\u2019re here.') and in the production build it's r.createElement("p",{},"We’re here.").

But it looks like I need to add the UTF-8 charset to my JS tags. I already had <meta charset="utf-8"> on my HTML page. When I added the charset to my JavaScript tag, as in <script charset="utf-8" type="text/javascript" src="minified.js"></script>, the characters are rendered correctly in Chrome, Firefox, and Safari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants