Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using webpack and react × becomes × with minification

I'm using webpack.optimize.UglifyJsPlugin() to minify my React code.

This is my render function

return (
    <div id='columnPicker' className='modal fade' tabIndex='-1' role='dialog'>
        <div className='modal-dialog modal-sm' role='document'>
            <div className='modal-content'>
                <div className='modal-header'>
                    <button type='button' className='close' data-dismiss='modal'>&times;</button>
                    <h4 className='modal-title'>Column Picker</h4>
                </div>
                <div className='modal-body'>
                    <ul className='list-group'>
                        {listItems}
                    </ul>
                </div>
                <div className='modal-footer'>
                    <div className='pull-right'>
                        <button type='button' className='btn btn-sm btn-primary' data-dismiss='modal' onClick={props.onSave}>Save</button>
                    </div>
                    <div className='pull-right'>
                        <button type='button' className='btn btn-link' data-dismiss='modal'>Cancel</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
);

The close button uses &times but when it actually renders I see

<button type="button" class="close" data-dismiss="modal">×</button>

If I remove webpack.optimize.UglifyJsPlugin() it renders as one would expect. Does anyone know how to fix this?

like image 385
Brett Koenig Avatar asked Jan 10 '17 16:01

Brett Koenig


People also ask

Can you use webpack With React?

Webpack is not the only bundler you could use (there is Browserify), but it has quickly become the bundler of choice for many React developers, and it is featured in more than a few React best practices blog posts and tutorials.

Do we need webpack in React?

We need its packages for the following reasons: webpack: The main webpack plugin as an engine for its dependents. webpack-cli: To access some webpack commands through CLI like starting dev server, creating production build, etc. webpack-dev-server: A minimal server for client-side development purpose only.

Why use webpack instead of create React app?

Configuring webpack provides complete control over the development environment, while initializing with Create React App prevents any custom configuration by default.


1 Answers

Specifying the charset in the HTML will preserve the correct character.

Try adding <meta charset="UTF-8"/> (or whatever charset) to the meta tag on your html file.

like image 132
Eric Avatar answered Sep 28 '22 04:09

Eric