提交 686f32fa 编写于 作者: 雪洛's avatar 雪洛 提交者: qiang

feat: auto import uniCloud once

上级 c6150e20
......@@ -63,8 +63,11 @@ const v3 = {
const statCode = getPlatformStat()
const pushCode = getPlatformPush()
const beforeCode = 'import \'uni-pages\';'
let beforeCode = 'import \'uni-pages\';'
if (JSON.parse(process.env.UNI_CLOUD_PROVIDER || '[]').length) {
const uniCloudLibPath = '@dcloudio/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js'
beforeCode += `import '${uniCloudLibPath}';`
}
if (!webpackConfig.optimization) {
webpackConfig.optimization = {}
}
......
......@@ -100,9 +100,12 @@ module.exports = {
useBuiltIns = babelConfig.presets[0][1].useBuiltIns
} catch (e) {}
const beforeCode = (useBuiltIns === 'entry' ? 'import \'@babel/polyfill\';' : '') +
let beforeCode = (useBuiltIns === 'entry' ? 'import \'@babel/polyfill\';' : '') +
`import 'uni-pages';import 'uni-${process.env.UNI_PLATFORM}';`
if (JSON.parse(process.env.UNI_CLOUD_PROVIDER || '[]').length) {
const uniCloudLibPath = '@dcloudio/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js'
beforeCode += `import '${uniCloudLibPath}';`
}
return {
resolve: {
extensions: ['.nvue'],
......
......@@ -194,6 +194,11 @@ module.exports = {
${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
}
if (JSON.parse(process.env.UNI_CLOUD_PROVIDER || '[]').length) {
const uniCloudLibPath = '@dcloudio/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js'
beforeCode += `import '${uniCloudLibPath}';`
}
const alias = { // 仅 mp-weixin
'mpvue-page-factory': require.resolve(
'@dcloudio/vue-cli-plugin-uni/packages/mpvue-page-factory')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册