Problems encountered:

Uncaught SyntaxError: < span style = “box-sizing: border-box; color: RGB (51, 51, 51); line-height: 22px; font-size: 14px! Important; word-break: break-all;” Invalid or unexpected token.

Solutions:

Conversion file encoding

1. Install webpack-encoding-plugin in current project (without –save-dev)

npm install webpack-encoding-plugin
Copy the code

2. Use the plug-in in the webpack.config.js file (note the order in which the two loaders are used)

//webpack.config.js const path = require('path'); const EncodingPlugin = require('webpack-encoding-plugin'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist') }, module: { rules: [ { test: /\.css$/, use: [ 'style-loader', 'css-loader' ], }, ], }, plugins: [new EncodingPlugin({ encoding: 'utf-8' })]};Copy the code

3. Set the character set in the HTML file

<! doctype html><html> <head> <title>Asset Management</title> </head> <body> <script src="bundle.js" charset="utf-8"></script> </body></html>Copy the code