提交 4e2ff83f 编写于 作者: fxy060608's avatar fxy060608

fix(mp): add common/assets (#3629)

上级 6bded21d
......@@ -52,3 +52,37 @@ export const COMMON_EXCLUDE = [
/\/@dcloudio\/uni-h5\/style/,
/\/@dcloudio\/uni-components\/style/,
]
export const KNOWN_ASSET_TYPES = [
// images
'png',
'jpe?g',
'gif',
'svg',
'ico',
'webp',
'avif',
// media
'mp4',
'webm',
'ogg',
'mp3',
'wav',
'flac',
'aac',
// fonts
'woff2?',
'eot',
'ttf',
'otf',
// other
'pdf',
'txt',
]
export const DEFAULT_ASSETS_RE = new RegExp(
`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`
)
......@@ -16,6 +16,7 @@ import {
M,
isMiniProgramAssetFile,
dynamicImportPolyfill,
DEFAULT_ASSETS_RE,
} from '@dcloudio/uni-cli-shared'
import { GetManualChunk, GetModuleInfo, PreRenderedChunk } from 'rollup'
import {
......@@ -121,6 +122,11 @@ function createMoveToVendorChunkFn(): GetManualChunk {
return (id, { getModuleInfo }) => {
const normalizedId = normalizePath(id)
const filename = normalizedId.split('?')[0]
// 处理资源文件
if (DEFAULT_ASSETS_RE.test(filename)) {
debugChunk('common/assets', normalizedId)
return 'common/assets'
}
// 处理项目内的js,ts文件
if (EXTNAME_JS_RE.test(filename)) {
if (filename.startsWith(inputDir) && !filename.includes('node_modules')) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册