在Babel配置中添加如下代码,使用"forceFileOutput"选项来控制Babel的输出文件编码:
module.exports = {
// ...
output: {
filename: 'bundle.js'
},
forceFileOutput: true,
output: {
filename: 'bundle.js',
encoding: 'utf-8'
}
}
上述代码可在Babel配置文件中使用,将Babel的输出文件编码设置为UTF-8。这样,在 Babel 运行时生成的文件,即 bundle.js,将会是使用 UTF-8 编码的文件。