在项目中使用了three.js,three.js支持commonJs写法,导致发布后提示ReferenceError: exports is not defined
解决办法:
-
执行以下命令添加babel/plugin-transform-modules-commonjs
npm install --save-dev @babel/plugin-transform-modules-commonjs
-
在babel.config.js 中添加
plugins: [
[
'@babel/plugin-transform-modules-commonjs'
]
]
//或者
plugins: [
[
'@babel/plugin-transform-modules-commonjs',
{
allowTopLevelThis: true
}
]
]
网友评论