提交 0f4d6497 编写于 作者: Q qiang

fix(mp): clone babelLoader and options for main.js

上级 3e9c68cb
......@@ -96,12 +96,21 @@ createPage(Page)
components: []
})
const babelLoader = findBabelLoader(this.loaders)
let babelLoader = findBabelLoader(this.loaders)
if (!babelLoader) {
throw new Error(uniI18n.__('mpLoader.findFail', {
0: 'babel-loader'
}))
} else {
const webpack = require('webpack')
if (webpack.version[0] > 4) {
// clone babelLoader and options
const index = this.loaders.indexOf(babelLoader)
const newBabelLoader = Object.assign({}, babelLoader)
Object.assign(newBabelLoader, { options: Object.assign({}, babelLoader.options) })
this.loaders.splice(index, 1, newBabelLoader)
babelLoader = newBabelLoader
}
addCreateApp(babelLoader)
}
......@@ -147,4 +156,4 @@ createPage(Page)
callback(err, content, map)
})
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册