Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
40b2aae3
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
40b2aae3
编写于
8月 03, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(app): css
上级
a43698c4
变更
16
展开全部
隐藏空白更改
内联
并排
Showing
16 changed file
with
14 addition
and
1318 deletion
+14
-1318
packages/uni-app-vite/dist/plugin/configResolved.js
packages/uni-app-vite/dist/plugin/configResolved.js
+5
-5
packages/uni-app-vite/dist/plugins/vitejs/constants.js
packages/uni-app-vite/dist/plugins/vitejs/constants.js
+0
-11
packages/uni-app-vite/dist/plugins/vitejs/plugins/asset.js
packages/uni-app-vite/dist/plugins/vitejs/plugins/asset.js
+0
-266
packages/uni-app-vite/dist/plugins/vitejs/plugins/css.js
packages/uni-app-vite/dist/plugins/vitejs/plugins/css.js
+0
-891
packages/uni-app-vite/dist/plugins/vitejs/utils.js
packages/uni-app-vite/dist/plugins/vitejs/utils.js
+0
-142
packages/uni-app-vite/src/plugin/configResolved.ts
packages/uni-app-vite/src/plugin/configResolved.ts
+2
-2
packages/uni-cli-shared/src/vite/plugins/index.ts
packages/uni-cli-shared/src/vite/plugins/index.ts
+3
-0
packages/uni-cli-shared/src/vite/plugins/vitejs/config.ts
packages/uni-cli-shared/src/vite/plugins/vitejs/config.ts
+1
-0
packages/uni-cli-shared/src/vite/plugins/vitejs/constants.ts
packages/uni-cli-shared/src/vite/plugins/vitejs/constants.ts
+0
-0
packages/uni-cli-shared/src/vite/plugins/vitejs/plugin.ts
packages/uni-cli-shared/src/vite/plugins/vitejs/plugin.ts
+1
-0
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/asset.ts
...s/uni-cli-shared/src/vite/plugins/vitejs/plugins/asset.ts
+0
-0
packages/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
...ges/uni-cli-shared/src/vite/plugins/vitejs/plugins/css.ts
+1
-1
packages/uni-cli-shared/src/vite/plugins/vitejs/utils.ts
packages/uni-cli-shared/src/vite/plugins/vitejs/utils.ts
+0
-0
packages/uni-cli-shared/tsconfig.json
packages/uni-cli-shared/tsconfig.json
+1
-0
packages/uni-cli-shared/types/alias.d.ts
packages/uni-cli-shared/types/alias.d.ts
+0
-0
packages/uni-cli-shared/types/shims.d.ts
packages/uni-cli-shared/types/shims.d.ts
+0
-0
未找到文件。
packages/uni-app-vite/dist/plugin/configResolved.js
浏览文件 @
40b2aae3
"
use strict
"
;
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
configResolved
=
void
0
;
exports
.
configResolved
=
void
0
;
const
asset_1
=
require
(
"
../plugins/vitejs/plugins/asset
"
);
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
css_1
=
require
(
"
../plugins/vitejs/plugins/css
"
);
const
uni_cli_shared_2
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
configResolved
=
(
config
)
=>
{
const
configResolved
=
(
config
)
=>
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
initCodeSpliting
(
config
);
initCodeSpliting
(
config
);
...
@@ -20,9 +20,9 @@ exports.configResolved = configResolved;
...
@@ -20,9 +20,9 @@ exports.configResolved = configResolved;
function
initCodeSpliting
(
config
)
{
function
initCodeSpliting
(
config
)
{
// 替换内置插件
// 替换内置插件
const
replacedPlugins
=
[
const
replacedPlugins
=
[
asset
_1
.
assetPlugin
(
config
),
uni_cli_shared
_1
.
assetPlugin
(
config
),
css_1
.
cssPlugin
(
config
),
uni_cli_shared_2
.
cssPlugin
(
config
),
css_1
.
cssPostPlugin
(
config
),
uni_cli_shared_2
.
cssPostPlugin
(
config
),
];
];
replacedPlugins
.
forEach
((
plugin
)
=>
{
replacedPlugins
.
forEach
((
plugin
)
=>
{
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
plugin
.
name
);
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
plugin
.
name
);
...
...
packages/uni-app-vite/dist/plugins/vitejs/constants.js
已删除
100644 → 0
浏览文件 @
a43698c4
"
use strict
"
;
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
CLIENT_PUBLIC_PATH
=
exports
.
FS_PREFIX
=
void
0
;
/**
* https://github.com/vitejs/vite/blob/main/packages/vite/src/node/constants.ts
*/
/**
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
*/
exports
.
FS_PREFIX
=
`/@fs/`
;
exports
.
CLIENT_PUBLIC_PATH
=
`/@vite/client`
;
packages/uni-app-vite/dist/plugins/vitejs/plugins/asset.js
已删除
100644 → 0
浏览文件 @
a43698c4
"
use strict
"
;
var
__createBinding
=
(
this
&&
this
.
__createBinding
)
||
(
Object
.
create
?
(
function
(
o
,
m
,
k
,
k2
)
{
if
(
k2
===
undefined
)
k2
=
k
;
Object
.
defineProperty
(
o
,
k2
,
{
enumerable
:
true
,
get
:
function
()
{
return
m
[
k
];
}
});
})
:
(
function
(
o
,
m
,
k
,
k2
)
{
if
(
k2
===
undefined
)
k2
=
k
;
o
[
k2
]
=
m
[
k
];
}));
var
__setModuleDefault
=
(
this
&&
this
.
__setModuleDefault
)
||
(
Object
.
create
?
(
function
(
o
,
v
)
{
Object
.
defineProperty
(
o
,
"
default
"
,
{
enumerable
:
true
,
value
:
v
});
})
:
function
(
o
,
v
)
{
o
[
"
default
"
]
=
v
;
});
var
__importStar
=
(
this
&&
this
.
__importStar
)
||
function
(
mod
)
{
if
(
mod
&&
mod
.
__esModule
)
return
mod
;
var
result
=
{};
if
(
mod
!=
null
)
for
(
var
k
in
mod
)
if
(
k
!==
"
default
"
&&
Object
.
prototype
.
hasOwnProperty
.
call
(
mod
,
k
))
__createBinding
(
result
,
mod
,
k
);
__setModuleDefault
(
result
,
mod
);
return
result
;
};
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
function
adopt
(
value
)
{
return
value
instanceof
P
?
value
:
new
P
(
function
(
resolve
)
{
resolve
(
value
);
});
}
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
[
"
throw
"
](
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
adopt
(
result
.
value
).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
||
[])).
next
());
});
};
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
urlToBuiltUrl
=
exports
.
getAssetHash
=
exports
.
getAssetFilename
=
exports
.
fileToUrl
=
exports
.
checkPublicFile
=
exports
.
registerAssetToChunk
=
exports
.
assetPlugin
=
exports
.
chunkToEmittedAssetsMap
=
exports
.
assetUrlRE
=
void
0
;
/**
* https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/asset.ts
*/
const
path_1
=
__importDefault
(
require
(
"
path
"
));
const
url_1
=
require
(
"
url
"
);
const
fs_1
=
__importStar
(
require
(
"
fs
"
));
const
lite_1
=
__importDefault
(
require
(
"
mime/lite
"
));
const
utils_1
=
require
(
"
../utils
"
);
const
constants_1
=
require
(
"
../constants
"
);
const
magic_string_1
=
__importDefault
(
require
(
"
magic-string
"
));
const
crypto_1
=
require
(
"
crypto
"
);
exports
.
assetUrlRE
=
/__VITE_ASSET__
([
a-z
\d]{8})
__
(?:\$
_
(
.*
?)
__
)?
/g
;
// urls in JS must be quoted as strings, so when replacing them we need
// a different regex
const
assetUrlQuotedRE
=
/"__VITE_ASSET__
([
a-z
\d]{8})
__
(?:\$
_
(
.*
?)
__
)?
"/g
;
const
rawRE
=
/
(\?
|&
)
raw
(?:
&|$
)
/
;
const
urlRE
=
/
(\?
|&
)
url
(?:
&|$
)
/
;
exports
.
chunkToEmittedAssetsMap
=
new
WeakMap
();
const
assetCache
=
new
WeakMap
();
const
assetHashToFilenameMap
=
new
WeakMap
();
// save hashes of the files that has been emitted in build watch
const
emittedHashMap
=
new
WeakMap
();
/**
* Also supports loading plain strings with import text from './foo.txt?raw'
*/
function
assetPlugin
(
config
)
{
// assetHashToFilenameMap initialization in buildStart causes getAssetFilename to return undefined
assetHashToFilenameMap
.
set
(
config
,
new
Map
());
return
{
name
:
'
vite:asset
'
,
buildStart
()
{
assetCache
.
set
(
config
,
new
Map
());
emittedHashMap
.
set
(
config
,
new
Set
());
},
resolveId
(
id
)
{
if
(
!
config
.
assetsInclude
(
utils_1
.
cleanUrl
(
id
)))
{
return
;
}
// imports to absolute urls pointing to files in /public
// will fail to resolve in the main resolver. handle them here.
const
publicFile
=
checkPublicFile
(
id
,
config
);
if
(
publicFile
)
{
return
id
;
}
},
load
(
id
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
if
(
id
.
startsWith
(
'
\
0
'
))
{
// Rollup convention, this id should be handled by the
// plugin that marked it with \0
return
;
}
// raw requests, read from disk
if
(
rawRE
.
test
(
id
))
{
const
file
=
checkPublicFile
(
id
,
config
)
||
utils_1
.
cleanUrl
(
id
);
// raw query, read file and return as string
return
`export default
${
JSON
.
stringify
(
yield
fs_1
.
promises
.
readFile
(
file
,
'
utf-8
'
))}
`
;
}
if
(
!
config
.
assetsInclude
(
utils_1
.
cleanUrl
(
id
))
&&
!
urlRE
.
test
(
id
))
{
return
;
}
id
=
id
.
replace
(
urlRE
,
'
$1
'
).
replace
(
/
[\?
&
]
$/
,
''
);
const
url
=
yield
fileToUrl
(
id
,
config
,
this
);
return
`export default
${
JSON
.
stringify
(
url
)}
`
;
});
},
renderChunk
(
code
,
chunk
)
{
let
match
;
let
s
;
while
((
match
=
assetUrlQuotedRE
.
exec
(
code
)))
{
s
=
s
||
(
s
=
new
magic_string_1
.
default
(
code
));
const
[
full
,
hash
,
postfix
=
''
]
=
match
;
// some internal plugins may still need to emit chunks (e.g. worker) so
// fallback to this.getFileName for that.
const
file
=
getAssetFilename
(
hash
,
config
)
||
this
.
getFileName
(
hash
);
registerAssetToChunk
(
chunk
,
file
);
const
outputFilepath
=
config
.
base
+
file
+
postfix
;
s
.
overwrite
(
match
.
index
,
match
.
index
+
full
.
length
,
JSON
.
stringify
(
outputFilepath
));
}
if
(
s
)
{
return
{
code
:
s
.
toString
(),
map
:
config
.
build
.
sourcemap
?
s
.
generateMap
({
hires
:
true
})
:
null
,
};
}
else
{
return
null
;
}
},
generateBundle
(
_
,
bundle
)
{
// do not emit assets for SSR build
if
(
config
.
command
===
'
build
'
&&
config
.
build
.
ssr
)
{
for
(
const
file
in
bundle
)
{
if
(
bundle
[
file
].
type
===
'
asset
'
&&
!
file
.
includes
(
'
ssr-manifest.json
'
))
{
delete
bundle
[
file
];
}
}
}
},
};
}
exports
.
assetPlugin
=
assetPlugin
;
function
registerAssetToChunk
(
chunk
,
file
)
{
let
emitted
=
exports
.
chunkToEmittedAssetsMap
.
get
(
chunk
);
if
(
!
emitted
)
{
emitted
=
new
Set
();
exports
.
chunkToEmittedAssetsMap
.
set
(
chunk
,
emitted
);
}
emitted
.
add
(
utils_1
.
cleanUrl
(
file
));
}
exports
.
registerAssetToChunk
=
registerAssetToChunk
;
function
checkPublicFile
(
url
,
{
publicDir
})
{
// note if the file is in /public, the resolver would have returned it
// as-is so it's not going to be a fully resolved path.
if
(
!
publicDir
||
!
url
.
startsWith
(
'
/
'
))
{
return
;
}
const
publicFile
=
path_1
.
default
.
join
(
publicDir
,
utils_1
.
cleanUrl
(
url
));
if
(
fs_1
.
default
.
existsSync
(
publicFile
))
{
return
publicFile
;
}
else
{
return
;
}
}
exports
.
checkPublicFile
=
checkPublicFile
;
function
fileToUrl
(
id
,
config
,
ctx
)
{
if
(
config
.
command
===
'
serve
'
)
{
return
fileToDevUrl
(
id
,
config
);
}
else
{
return
fileToBuiltUrl
(
id
,
config
,
ctx
);
}
}
exports
.
fileToUrl
=
fileToUrl
;
function
fileToDevUrl
(
id
,
config
)
{
let
rtn
;
if
(
checkPublicFile
(
id
,
config
))
{
// in public dir, keep the url as-is
rtn
=
id
;
}
else
if
(
id
.
startsWith
(
config
.
root
))
{
// in project root, infer short public path
rtn
=
'
/
'
+
path_1
.
default
.
posix
.
relative
(
config
.
root
,
id
);
}
else
{
// outside of project root, use absolute fs path
// (this is special handled by the serve static middleware
rtn
=
path_1
.
default
.
posix
.
join
(
constants_1
.
FS_PREFIX
+
id
);
}
return
config
.
base
+
rtn
.
replace
(
/^
\/
/
,
''
);
}
function
getAssetFilename
(
hash
,
config
)
{
var
_a
;
return
(
_a
=
assetHashToFilenameMap
.
get
(
config
))
===
null
||
_a
===
void
0
?
void
0
:
_a
.
get
(
hash
);
}
exports
.
getAssetFilename
=
getAssetFilename
;
/**
* Register an asset to be emitted as part of the bundle (if necessary)
* and returns the resolved public URL
*/
function
fileToBuiltUrl
(
id
,
config
,
pluginContext
,
skipPublicCheck
=
false
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
if
(
!
skipPublicCheck
&&
checkPublicFile
(
id
,
config
))
{
return
config
.
base
+
id
.
slice
(
1
);
}
const
cache
=
assetCache
.
get
(
config
);
const
cached
=
cache
.
get
(
id
);
if
(
cached
)
{
return
cached
;
}
const
file
=
utils_1
.
cleanUrl
(
id
);
const
content
=
yield
fs_1
.
promises
.
readFile
(
file
);
let
url
;
if
(
config
.
build
.
lib
||
(
!
file
.
endsWith
(
'
.svg
'
)
&&
content
.
length
<
Number
(
config
.
build
.
assetsInlineLimit
)))
{
// base64 inlined as a string
url
=
`data:
${
lite_1
.
default
.
getType
(
file
)}
;base64,
${
content
.
toString
(
'
base64
'
)}
`
;
}
else
{
// emit as asset
// rollup supports `import.meta.ROLLUP_FILE_URL_*`, but it generates code
// that uses runtime url sniffing and it can be verbose when targeting
// non-module format. It also fails to cascade the asset content change
// into the chunk's hash, so we have to do our own content hashing here.
// https://bundlers.tooling.report/hashing/asset-cascade/
// https://github.com/rollup/rollup/issues/3415
const
map
=
assetHashToFilenameMap
.
get
(
config
);
const
contentHash
=
getAssetHash
(
content
);
const
{
search
,
hash
}
=
url_1
.
parse
(
id
);
const
postfix
=
(
search
||
''
)
+
(
hash
||
''
);
const
basename
=
path_1
.
default
.
basename
(
file
);
const
ext
=
path_1
.
default
.
extname
(
basename
);
const
fileName
=
path_1
.
default
.
posix
.
join
(
config
.
build
.
assetsDir
,
`
${
basename
.
slice
(
0
,
-
ext
.
length
)}
.
${
contentHash
}${
ext
}
`
);
if
(
!
map
.
has
(
contentHash
))
{
map
.
set
(
contentHash
,
fileName
);
}
const
emittedSet
=
emittedHashMap
.
get
(
config
);
if
(
!
emittedSet
.
has
(
contentHash
))
{
pluginContext
.
emitFile
({
fileName
,
type
:
'
asset
'
,
source
:
content
,
});
emittedSet
.
add
(
contentHash
);
}
url
=
`__VITE_ASSET__
${
contentHash
}
__
${
postfix
?
`$_
${
postfix
}
__`
:
``
}
`
;
}
cache
.
set
(
id
,
url
);
return
url
;
});
}
function
getAssetHash
(
content
)
{
return
crypto_1
.
createHash
(
'
sha256
'
).
update
(
content
).
digest
(
'
hex
'
).
slice
(
0
,
8
);
}
exports
.
getAssetHash
=
getAssetHash
;
function
urlToBuiltUrl
(
url
,
importer
,
config
,
pluginContext
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
if
(
checkPublicFile
(
url
,
config
))
{
return
config
.
base
+
url
.
slice
(
1
);
}
const
file
=
url
.
startsWith
(
'
/
'
)
?
path_1
.
default
.
join
(
config
.
root
,
url
)
:
path_1
.
default
.
join
(
path_1
.
default
.
dirname
(
importer
),
url
);
return
fileToBuiltUrl
(
file
,
config
,
pluginContext
,
// skip public check since we just did it above
true
);
});
}
exports
.
urlToBuiltUrl
=
urlToBuiltUrl
;
packages/uni-app-vite/dist/plugins/vitejs/plugins/css.js
已删除
100644 → 0
浏览文件 @
a43698c4
此差异已折叠。
点击以展开。
packages/uni-app-vite/dist/plugins/vitejs/utils.js
已删除
100644 → 0
浏览文件 @
a43698c4
"
use strict
"
;
var
__awaiter
=
(
this
&&
this
.
__awaiter
)
||
function
(
thisArg
,
_arguments
,
P
,
generator
)
{
function
adopt
(
value
)
{
return
value
instanceof
P
?
value
:
new
P
(
function
(
resolve
)
{
resolve
(
value
);
});
}
return
new
(
P
||
(
P
=
Promise
))(
function
(
resolve
,
reject
)
{
function
fulfilled
(
value
)
{
try
{
step
(
generator
.
next
(
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
rejected
(
value
)
{
try
{
step
(
generator
[
"
throw
"
](
value
));
}
catch
(
e
)
{
reject
(
e
);
}
}
function
step
(
result
)
{
result
.
done
?
resolve
(
result
.
value
)
:
adopt
(
result
.
value
).
then
(
fulfilled
,
rejected
);
}
step
((
generator
=
generator
.
apply
(
thisArg
,
_arguments
||
[])).
next
());
});
};
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
processSrcSet
=
exports
.
generateCodeFrame
=
exports
.
posToNumber
=
exports
.
pad
=
exports
.
isObject
=
exports
.
asyncReplace
=
exports
.
isDataUrl
=
exports
.
dataUrlRE
=
exports
.
isExternalUrl
=
exports
.
externalRE
=
exports
.
cleanUrl
=
exports
.
hashRE
=
exports
.
queryRE
=
exports
.
normalizePath
=
exports
.
isWindows
=
exports
.
deepImportRE
=
exports
.
bareImportRE
=
exports
.
slash
=
void
0
;
/**
* https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts
*/
const
os_1
=
__importDefault
(
require
(
"
os
"
));
const
path_1
=
__importDefault
(
require
(
"
path
"
));
function
slash
(
p
)
{
return
p
.
replace
(
/
\\
/g
,
'
/
'
);
}
exports
.
slash
=
slash
;
exports
.
bareImportRE
=
/^
[\w
@
](?!
.*:
\/\/)
/
;
exports
.
deepImportRE
=
/^
([^
@
][^/]
*
)\/
|^
(
@
[^/]
+
\/[^/]
+
)\/
/
;
exports
.
isWindows
=
os_1
.
default
.
platform
()
===
'
win32
'
;
function
normalizePath
(
id
)
{
return
path_1
.
default
.
posix
.
normalize
(
exports
.
isWindows
?
slash
(
id
)
:
id
);
}
exports
.
normalizePath
=
normalizePath
;
exports
.
queryRE
=
/
\?
.*$/
s
;
exports
.
hashRE
=
/#.*$/
s
;
const
cleanUrl
=
(
url
)
=>
url
.
replace
(
exports
.
hashRE
,
''
).
replace
(
exports
.
queryRE
,
''
);
exports
.
cleanUrl
=
cleanUrl
;
exports
.
externalRE
=
/^
(
https
?
:
)?\/\/
/
;
const
isExternalUrl
=
(
url
)
=>
exports
.
externalRE
.
test
(
url
);
exports
.
isExternalUrl
=
isExternalUrl
;
exports
.
dataUrlRE
=
/^
\s
*data:/i
;
const
isDataUrl
=
(
url
)
=>
exports
.
dataUrlRE
.
test
(
url
);
exports
.
isDataUrl
=
isDataUrl
;
function
asyncReplace
(
input
,
re
,
replacer
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
let
match
;
let
remaining
=
input
;
let
rewritten
=
''
;
while
((
match
=
re
.
exec
(
remaining
)))
{
rewritten
+=
remaining
.
slice
(
0
,
match
.
index
);
rewritten
+=
yield
replacer
(
match
);
remaining
=
remaining
.
slice
(
match
.
index
+
match
[
0
].
length
);
}
rewritten
+=
remaining
;
return
rewritten
;
});
}
exports
.
asyncReplace
=
asyncReplace
;
function
isObject
(
value
)
{
return
Object
.
prototype
.
toString
.
call
(
value
)
===
'
[object Object]
'
;
}
exports
.
isObject
=
isObject
;
const
splitRE
=
/
\r?\n
/
;
const
range
=
2
;
function
pad
(
source
,
n
=
2
)
{
const
lines
=
source
.
split
(
splitRE
);
return
lines
.
map
((
l
)
=>
` `
.
repeat
(
n
)
+
l
).
join
(
`\n`
);
}
exports
.
pad
=
pad
;
function
posToNumber
(
source
,
pos
)
{
if
(
typeof
pos
===
'
number
'
)
return
pos
;
const
lines
=
source
.
split
(
splitRE
);
const
{
line
,
column
}
=
pos
;
let
start
=
0
;
for
(
let
i
=
0
;
i
<
line
-
1
;
i
++
)
{
start
+=
lines
[
i
].
length
+
1
;
}
return
start
+
column
;
}
exports
.
posToNumber
=
posToNumber
;
function
generateCodeFrame
(
source
,
start
=
0
,
end
)
{
start
=
posToNumber
(
source
,
start
);
end
=
end
||
start
;
const
lines
=
source
.
split
(
splitRE
);
let
count
=
0
;
const
res
=
[];
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
count
+=
lines
[
i
].
length
+
1
;
if
(
count
>=
start
)
{
for
(
let
j
=
i
-
range
;
j
<=
i
+
range
||
end
>
count
;
j
++
)
{
if
(
j
<
0
||
j
>=
lines
.
length
)
continue
;
const
line
=
j
+
1
;
res
.
push
(
`
${
line
}${
'
'
.
repeat
(
Math
.
max
(
3
-
String
(
line
).
length
,
0
))}
|
${
lines
[
j
]}
`
);
const
lineLength
=
lines
[
j
].
length
;
if
(
j
===
i
)
{
// push underline
const
pad
=
start
-
(
count
-
lineLength
)
+
1
;
const
length
=
Math
.
max
(
1
,
end
>
count
?
lineLength
-
pad
:
end
-
start
);
res
.
push
(
` | `
+
'
'
.
repeat
(
pad
)
+
'
^
'
.
repeat
(
length
));
}
else
if
(
j
>
i
)
{
if
(
end
>
count
)
{
const
length
=
Math
.
max
(
Math
.
min
(
end
-
count
,
lineLength
),
1
);
res
.
push
(
` | `
+
'
^
'
.
repeat
(
length
));
}
count
+=
lineLength
+
1
;
}
}
break
;
}
}
return
res
.
join
(
'
\n
'
);
}
exports
.
generateCodeFrame
=
generateCodeFrame
;
const
escapedSpaceCharacters
=
/
(
|
\\
t|
\\
n|
\\
f|
\\
r
)
+/g
;
function
processSrcSet
(
srcs
,
replacer
)
{
return
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
const
imageCandidates
=
srcs
.
split
(
'
,
'
)
.
map
((
s
)
=>
{
const
[
url
,
descriptor
]
=
s
.
replace
(
escapedSpaceCharacters
,
'
'
)
.
trim
()
.
split
(
'
'
,
2
);
return
{
url
,
descriptor
};
})
.
filter
(({
url
})
=>
!!
url
);
const
ret
=
yield
Promise
.
all
(
imageCandidates
.
map
(({
url
,
descriptor
})
=>
__awaiter
(
this
,
void
0
,
void
0
,
function
*
()
{
return
{
url
:
yield
replacer
({
url
,
descriptor
}),
descriptor
,
};
})));
const
url
=
ret
.
reduce
((
prev
,
{
url
,
descriptor
},
index
)
=>
{
descriptor
=
descriptor
||
''
;
return
(
prev
+=
url
+
`
${
descriptor
}${
index
===
ret
.
length
-
1
?
''
:
'
,
'
}
`
);
},
''
);
return
url
;
});
}
exports
.
processSrcSet
=
processSrcSet
;
packages/uni-app-vite/src/plugin/configResolved.ts
浏览文件 @
40b2aae3
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
assetPlugin
}
from
'
../plugins/vitejs/plugins/asset
'
import
{
assetPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
cssPlugin
,
cssPostPlugin
}
from
'
../plugins/vitejs/plugins/css
'
import
{
cssPlugin
,
cssPostPlugin
}
from
'
@dcloudio/uni-cli-shared
'
export
const
configResolved
:
Plugin
[
'
configResolved
'
]
=
(
config
)
=>
{
export
const
configResolved
:
Plugin
[
'
configResolved
'
]
=
(
config
)
=>
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
...
...
packages/uni-cli-shared/src/vite/plugins/index.ts
浏览文件 @
40b2aae3
...
@@ -3,3 +3,6 @@ export * from './copy'
...
@@ -3,3 +3,6 @@ export * from './copy'
export
*
from
'
./inject
'
export
*
from
'
./inject
'
export
*
from
'
./mainJs
'
export
*
from
'
./mainJs
'
export
*
from
'
./jsonJs
'
export
*
from
'
./jsonJs
'
export
{
assetPlugin
}
from
'
./vitejs/plugins/asset
'
export
{
cssPlugin
,
cssPostPlugin
}
from
'
./vitejs/plugins/css
'
packages/uni-cli-shared/src/vite/plugins/vitejs/config.ts
0 → 100644
浏览文件 @
40b2aae3
export
{
ResolvedConfig
}
from
'
vite
'
packages/uni-
app-vite/src
/plugins/vitejs/constants.ts
→
packages/uni-
cli-shared/src/vite
/plugins/vitejs/constants.ts
浏览文件 @
40b2aae3
文件已移动
packages/uni-cli-shared/src/vite/plugins/vitejs/plugin.ts
0 → 100644
浏览文件 @
40b2aae3
export
{
Plugin
}
from
'
vite
'
packages/uni-
app-vite/src
/plugins/vitejs/plugins/asset.ts
→
packages/uni-
cli-shared/src/vite
/plugins/vitejs/plugins/asset.ts
浏览文件 @
40b2aae3
文件已移动
packages/uni-
app-vite/src
/plugins/vitejs/plugins/css.ts
→
packages/uni-
cli-shared/src/vite
/plugins/vitejs/plugins/css.ts
浏览文件 @
40b2aae3
...
@@ -43,7 +43,7 @@ import type Sass from 'sass'
...
@@ -43,7 +43,7 @@ import type Sass from 'sass'
// and causes the CI tests fail, see: https://github.com/vitejs/vite/pull/2860
// and causes the CI tests fail, see: https://github.com/vitejs/vite/pull/2860
import
type
Stylus
from
'
stylus
'
import
type
Stylus
from
'
stylus
'
import
type
Less
from
'
less
'
import
type
Less
from
'
less
'
import
{
Alias
}
from
'
../../../../types/alias
'
import
{
Alias
}
from
'
../../../../
../
types/alias
'
// const debug = createDebugger('vite:css')
// const debug = createDebugger('vite:css')
...
...
packages/uni-
app-vite/src
/plugins/vitejs/utils.ts
→
packages/uni-
cli-shared/src/vite
/plugins/vitejs/utils.ts
浏览文件 @
40b2aae3
文件已移动
packages/uni-cli-shared/tsconfig.json
浏览文件 @
40b2aae3
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
},
},
"include"
:
[
"include"
:
[
"src"
,
"src"
,
"types/shims.d.ts"
,
"../shims-node.d.ts"
,
"../shims-node.d.ts"
,
"../shims-uni-app.d.ts"
"../shims-uni-app.d.ts"
]
]
...
...
packages/uni-
app-vite
/types/alias.d.ts
→
packages/uni-
cli-shared
/types/alias.d.ts
浏览文件 @
40b2aae3
文件已移动
packages/uni-
app-vite
/types/shims.d.ts
→
packages/uni-
cli-shared
/types/shims.d.ts
浏览文件 @
40b2aae3
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录