From ad038a28246a6e9fba1a46d0680dd1fe889e999b Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 20 Dec 2019 12:10:44 +0800 Subject: [PATCH] fix(cli): compatible with vue cli4 --- packages/vue-cli-plugin-uni/lib/env.js | 4 +++ .../packages/vue-template-compiler/index.js | 34 +++++++++---------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 57226787d..d6ffb9e6a 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -260,6 +260,10 @@ moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pa if (process.env.UNI_USING_V3 && process.env.UNI_PLATFORM === 'app-plus') { moduleAlias.addAlias('vue-style-loader', '@dcloudio/vue-cli-plugin-uni/packages/app-vue-style-loader') } + +if (process.env.UNI_PLATFORM === 'h5') { + moduleAlias.addAlias('vue-style-loader', '@dcloudio/vue-cli-plugin-uni/packages/h5-vue-style-loader') +} // vue cache if ( // 非 h5 ,非 v3,非 native diff --git a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/index.js b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/index.js index dcc7e6cbe..81b4a1205 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/index.js +++ b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/index.js @@ -1,20 +1,20 @@ -try { - var vueVersion = require('vue').version -} catch (e) {} +// try { +// var vueVersion = require('vue').version +// } catch (e) {} -var packageName = require('./package.json').name -var packageVersion = require('./package.json').version -if (vueVersion && vueVersion !== packageVersion) { - var vuePath = require.resolve('vue') - var packagePath = require.resolve('./package.json') - throw new Error( - '\n\nVue packages version mismatch:\n\n' + - '- vue@' + vueVersion + ' (' + vuePath + ')\n' + - '- ' + packageName + '@' + packageVersion + ' (' + packagePath + ')\n\n' + - 'This may cause things to work incorrectly. Make sure to use the same version for both.\n' + - 'If you are using vue-loader@>=10.0, simply update vue-template-compiler.\n' + - 'If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump ' + packageName + ' to the latest.\n' - ) -} +// var packageName = require('./package.json').name +// var packageVersion = require('./package.json').version +// if (vueVersion && vueVersion !== packageVersion) { +// var vuePath = require.resolve('vue') +// var packagePath = require.resolve('./package.json') +// throw new Error( +// '\n\nVue packages version mismatch:\n\n' + +// '- vue@' + vueVersion + ' (' + vuePath + ')\n' + +// '- ' + packageName + '@' + packageVersion + ' (' + packagePath + ')\n\n' + +// 'This may cause things to work incorrectly. Make sure to use the same version for both.\n' + +// 'If you are using vue-loader@>=10.0, simply update vue-template-compiler.\n' + +// 'If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump ' + packageName + ' to the latest.\n' +// ) +// } module.exports = require('./build') -- GitLab