problem:
React with the project after webpack packaged, deployed to the server, and then directly access the index.html file packaged, there have been Chinese garbled.
Solution:
When webpack packaging, using webpack-encoding-plugin
plug-ins can be resolved. Steps are as follows:
The first step in installing webpack-encoding-plugin plugin
cnpm i webpack-encoding-plugin -D
The second step configuration file webpack.config.js
Add plug-in webpack.config.js file:
const EncodingPlugin = require('webpack-encoding-plugin');
module.exports = {
// ......
plugins: [
new EncodingPlugin({
encoding: 'UTF-8'
})
]
}
After the completion of the operation, re-run packaging commands, files will not appear garbled.