diff --git a/build/manifest.js b/build/manifest.js index 30ffc626ccc9d147512d7762c968d1d7497a200c..06bd8f7a27afc51f4d12c4678a19df9c8819bbb0 100644 --- a/build/manifest.js +++ b/build/manifest.js @@ -31,6 +31,8 @@ const DEPS = { ['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation'] ], 'previewImage': [ + ['/core/view/components/swiper/index.vue', 'Swiper'], + ['/core/view/components/swiper-item/index.vue', 'SwiperItem'], ['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage'] ], 'showToast': TOAST_DEPS, @@ -138,4 +140,4 @@ module.exports = { JSON.stringify(manifestJson, null, 4) ) } -} +} diff --git a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js index 893b45f6b636dbc2b59884905b7f93b06bb946b2..b8191d4420a9d04c23d5b882455cec9997b11196 100644 --- a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js +++ b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js @@ -1,5 +1,6 @@ const fs = require('fs') const path = require('path') +const updateComponents = require('./component') const tmpDir = path.resolve(__dirname, '../../.tmp') @@ -72,6 +73,12 @@ function updateAppComponents(paths) { return updateExportDefaultObject(paths, 'app-components.js', false) } +function updateCoreComponents(paths){ + const tags = process.UNI_TAGS || new Set() + Object.keys(paths).forEach(tag => tags.add(tag.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase())) + updateComponents(tags) +} + function updateAppMixins(paths) { return updateExportDefaultObject(paths, 'app-mixins.js', false, true) } @@ -93,6 +100,11 @@ const isAppComponents = filepath => { filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/components/app/') === 0 } +const isCoreComponents = filepath => { + return path.extname(filepath) === '.vue' && + filepath.indexOf('/core/view/components/') === 0 +} + const isAppMixins = filepath => { return path.extname(filepath) === '.js' && filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/components/app/') === 0 @@ -113,6 +125,7 @@ function parseDeps(apis, manifest) { const apiProtocolPaths = Object.create(null) const invokeApiPaths = Object.create(null) const appComponentsPaths = Object.create(null) + const coreComponentsPaths = Object.create(null) const appMixinsPaths = Object.create(null) const systemRoutesPaths = Object.create(null) const apiSubscribePaths = Object.create(null) @@ -126,6 +139,9 @@ function parseDeps(apis, manifest) { }, { test: isAppComponents, paths: appComponentsPaths + }, { + test: isCoreComponents, + paths: coreComponentsPaths }, { test: isAppMixins, paths: appMixinsPaths @@ -159,7 +175,7 @@ function parseDeps(apis, manifest) { }) if (strategy) { strategy.paths[exports] = filepath - } else { + } else { console.log('dep',name,dep) console.warn(`${filepath} 未识别`) } @@ -175,6 +191,7 @@ function parseDeps(apis, manifest) { apiProtocolPaths, invokeApiPaths, appComponentsPaths, + coreComponentsPaths, appMixinsPaths, systemRoutesPaths, apiSubscribePaths @@ -203,6 +220,7 @@ module.exports = function updateApis(apis = new Set(), userApis = new Set()) { invokeApiPaths, apiSubscribePaths, appComponentsPaths, + coreComponentsPaths, appMixinsPaths, systemRoutesPaths } = parseDeps(apis, manifest) @@ -214,6 +232,7 @@ module.exports = function updateApis(apis = new Set(), userApis = new Set()) { updateInvokeApi(invokeApiPaths) updateAppComponents(appComponentsPaths) + updateCoreComponents(coreComponentsPaths) updateAppMixins(appMixinsPaths) updateSystemRoutes(systemRoutesPaths) -} +}