diff --git a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js index 9b6edfc7ed5163e1c0bba62e00102232b85a0d9a..f8584d17309bf2c388ea218c2a97ea481a9f48f5 100644 --- a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js +++ b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js @@ -6,16 +6,26 @@ const { capitalize } = require('./util') -const platformTags = ['audio', 'map', 'video', 'web-view', 'cover-view', 'cover-image'] +const platformTags = ['audio', 'map', 'video', 'web-view', 'cover-view', 'cover-image', 'picker'] -//input 在 pageHead 中有使用,resize-sensor 在很多组件中有使用,暂时直接加载 -const autoloadTags = ['input', 'resize-sensor'] +const autoloadTags = { + // input 在 pageHead 中有使用,resize-sensor 在很多组件中有使用,暂时直接加载 + root: ['input', 'resize-sensor'], + other: { + picker: ['picker-view', 'picker-view-column'] + } +} module.exports = function updateComponents(tags) { - autoloadTags.forEach(tagName => { + autoloadTags.root.forEach(tagName => { tags.add(tagName) }) tags = [...tags] + Object.keys(autoloadTags.other).forEach(tagName => { + if (tags.includes(tagName)) { + tags.push(...autoloadTags.other[tagName]) + } + }) const importsStr = tags.map(tagName => { if (platformTags.indexOf(tagName) !== -1) { return `import ${capitalize(camelize(tagName))} from 'uni-platform/view/components/${tagName}'` @@ -44,4 +54,4 @@ ${componentsStr} fs.writeFileSync(path.resolve(dir, 'components.js'), content, 'utf8') -} +}