From a5dd1b6e309d25938c0c584598d183442c26a75f Mon Sep 17 00:00:00 2001 From: zoomchan-cxj Date: Tue, 21 Mar 2023 13:36:32 +0800 Subject: [PATCH] refactor(demo): change vue-loader dependency judgement --- .../hippy-vue-demo/scripts/hippy-webpack.android-vendor.js | 3 ++- examples/hippy-vue-demo/scripts/hippy-webpack.android.js | 3 ++- examples/hippy-vue-demo/scripts/hippy-webpack.dev.js | 3 ++- examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js | 3 ++- examples/hippy-vue-demo/scripts/hippy-webpack.ios.js | 3 ++- .../hippy-vue-demo/scripts/hippy-webpack.web-renderer.dev.js | 3 ++- examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.js | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js b/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js index 8c0e4f2c693..7bd76b3a139 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.android-vendor.js @@ -8,7 +8,8 @@ const platform = 'android'; let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin')); diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.android.js b/examples/hippy-vue-demo/scripts/hippy-webpack.android.js index dc9177cd074..b7a42a1c073 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.android.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.android.js @@ -19,7 +19,8 @@ if (fs.existsSync(hippyVueCssLoaderPath)) { let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin')); diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.dev.js b/examples/hippy-vue-demo/scripts/hippy-webpack.dev.js index 90eecb018a6..8bf1a2306de 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.dev.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.dev.js @@ -17,7 +17,8 @@ if (fs.existsSync(hippyVueCssLoaderPath)) { let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin')); diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js b/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js index 01fbe48c596..9d04455b698 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.ios-vendor.js @@ -8,7 +8,8 @@ const platform = 'ios'; let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin')); diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js b/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js index 767687832b9..f16be6650ca 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.ios.js @@ -19,7 +19,8 @@ if (fs.existsSync(hippyVueCssLoaderPath)) { let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin')); diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.dev.js b/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.dev.js index 48f4c592ccb..959cb07ef1a 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.dev.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.dev.js @@ -18,7 +18,8 @@ if (fs.existsSync(hippyVueCssLoaderPath)) { let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin')); diff --git a/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.js b/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.js index 03a494a9158..11a21f35f72 100644 --- a/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.js +++ b/examples/hippy-vue-demo/scripts/hippy-webpack.web-renderer.js @@ -18,7 +18,8 @@ if (fs.existsSync(hippyVueCssLoaderPath)) { let vueLoader = '@hippy/vue-loader'; let VueLoaderPlugin; const hippyVueLoaderPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib'); -if (fs.existsSync(hippyVueLoaderPath)) { +const hippyVueLoaderNodeModulesPath = path.resolve(__dirname, '../../../packages/hippy-vue-loader/node_modules'); +if (fs.existsSync(hippyVueLoaderNodeModulesPath) && fs.existsSync(hippyVueLoaderPath)) { console.warn(`* Using the @hippy/vue-loader in ${hippyVueLoaderPath}`); vueLoader = hippyVueLoaderPath; VueLoaderPlugin = require(path.resolve(__dirname, '../../../packages/hippy-vue-loader/lib/plugin'));