由于mpvue各种坑爹,公司业务需求需要转uni-app,按照教程尝试了一下,打包npm run dev:mp-weixin,出现报错如附件。我尝试了babel-loader的各种兼容es6的配置,但是都无效,然后我对比了官方的例子,babel配置一样,但是我这边会报扩展符为无效语法。
这是我的babel.config.js文件
const plugins = []
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
])
})
module.exports = {
presets: [
"es2015",
'stage-2',
[
'@vue/app',
{
useBuiltIns: 'entry'
}
]
],
plugins
}
npm run info ---------------
uni-app v2.5.1
uni-app cli v2.0.0-25120200103006
Environment Info:
System:
OS: macOS 10.15.2
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 11.10.0 - /usr/local/bin/node
Yarn: Not Found
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.117
Firefox: 71.0
Safari: 13.0.4
npmPackages:
@dcloudio/uni-app-plus: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-app-plus-nvue: 0.0.1
@dcloudio/uni-app-plus-nvue-v8: 0.0.1
@dcloudio/uni-cli-shared: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-h5: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-helper-json: * => 1.0.4
@dcloudio/uni-migration: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-mp-alipay: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-mp-baidu: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-mp-qq: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-mp-toutiao: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-mp-weixin: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-stat: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/uni-template-compiler: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/vue-cli-plugin-uni: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/webpack-uni-mp-loader: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@dcloudio/webpack-uni-nvue-loader: 0.0.1
@dcloudio/webpack-uni-pages-loader: ^2.0.0-25120200103006 => 2.0.0-25120200103006
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.1.2
@vue/babel-preset-app: 3.12.1
@vue/babel-preset-jsx: 1.1.2
@vue/babel-sugar-functional-vue: 1.1.2
@vue/babel-sugar-inject-h: 1.1.2
@vue/babel-sugar-v-model: 1.1.2
@vue/babel-sugar-v-on: 1.1.2
@vue/cli-overlay: 3.12.1
@vue/cli-plugin-babel: 3.5.1 => 3.5.1
@vue/cli-service: ^3.0.4 => 3.12.1
@vue/cli-shared-utils: 3.12.1
@vue/component-compiler-utils: 3.1.1 (3.1.1)
@vue/preload-webpack-plugin: 1.1.1
@vue/web-component-wrapper: 1.2.0
mpvue-page-factory: 1.0.1
mpvue-template-compiler: 1.0.13
uni-h5-vue: 2.6.10
uni-mp-vue: 2.6.10
vue: ^2.6.10 => 2.6.11
vue-hot-reload-api: 2.3.4
vue-loader: 15.8.3
vue-router: 3.0.1
vue-style-loader: ^3.0.1 => 3.1.2 (4.1.2, 3.1.2)
vue-template-compiler: ^2.6.10 => 2.6.11
vue-template-es2015-compiler: 1.9.1
vuex: ^3.0.1 => 3.1.2
npmGlobalPackages:
@vue/cli: 3.0.4
2***@qq.com (作者)
目前没发现其他问题,编译的时候只是报了扩展符的错误,对了,我是通过cli开出来的项目,而且是在webstorm编辑器开发的,不知道有没有影响
2020-01-10 14:29
2***@qq.com (作者)
公司项目目前在转型,非常期待您的回复,感激不尽
2020-01-10 14:31
2***@qq.com (作者)
我查询了一下loader,发现是版本冲突问题,问题已解决,谢谢
2020-01-10 18:44