Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
dbea30e6
U
uni-app
项目概览
qianlong66
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
dbea30e6
编写于
8月 03, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(app): css
上级
ef535ea1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
49 addition
and
56 deletion
+49
-56
packages/uni-app-vite/dist/plugin/configResolved.js
packages/uni-app-vite/dist/plugin/configResolved.js
+3
-27
packages/uni-app-vite/src/plugin/configResolved.ts
packages/uni-app-vite/src/plugin/configResolved.ts
+7
-27
packages/uni-cli-nvue/package.json
packages/uni-cli-nvue/package.json
+1
-1
packages/uni-cli-shared/src/vite/utils/index.ts
packages/uni-cli-shared/src/vite/utils/index.ts
+1
-0
packages/uni-cli-shared/src/vite/utils/plugin.ts
packages/uni-cli-shared/src/vite/utils/plugin.ts
+35
-1
tsconfig.json
tsconfig.json
+2
-0
未找到文件。
packages/uni-app-vite/dist/plugin/configResolved.js
浏览文件 @
dbea30e6
...
...
@@ -2,41 +2,17 @@
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
configResolved
=
void
0
;
const
uni_cli_shared_1
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
uni_cli_shared_2
=
require
(
"
@dcloudio/uni-cli-shared
"
);
const
configResolved
=
(
config
)
=>
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
initCodeSpliting
(
config
);
}
else
{
// 移除 vite 内置的 css post 处理,交由 @dcloudio/uni-cli-shared 的 uniCssPlugin 实现
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
'
vite:css-post
'
);
if
(
index
>
-
1
)
{
;
config
.
plugins
.
splice
(
index
,
1
);
}
uni_cli_shared_1
.
removePlugins
([
'
vite:asset
'
,
'
vite:css-post
'
],
config
);
}
};
exports
.
configResolved
=
configResolved
;
function
initCodeSpliting
(
config
)
{
// 替换内置插件
const
replacedPlugins
=
[
uni_cli_shared_1
.
assetPlugin
(
config
),
uni_cli_shared_2
.
cssPlugin
(
config
),
uni_cli_shared_2
.
cssPostPlugin
(
config
),
];
replacedPlugins
.
forEach
((
plugin
)
=>
{
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
plugin
.
name
);
if
(
index
>
-
1
)
{
;
config
.
plugins
.
splice
(
index
,
1
,
plugin
);
}
});
const
removedPlugins
=
[
'
vite:import-analysis
'
];
removedPlugins
.
forEach
((
name
)
=>
{
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
name
);
if
(
index
>
-
1
)
{
;
config
.
plugins
.
splice
(
index
,
1
);
}
});
uni_cli_shared_1
.
removePlugins
(
'
vite:import-analysis
'
,
config
);
uni_cli_shared_1
.
injectAssetAndCssPlugins
(
config
);
}
packages/uni-app-vite/src/plugin/configResolved.ts
浏览文件 @
dbea30e6
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
assetPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
cssPlugin
,
cssPostPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
removePlugins
,
injectAssetAndCssPlugins
,
}
from
'
@dcloudio/uni-cli-shared
'
export
const
configResolved
:
Plugin
[
'
configResolved
'
]
=
(
config
)
=>
{
if
(
process
.
env
.
UNI_APP_CODE_SPLITING
)
{
initCodeSpliting
(
config
as
ResolvedConfig
)
}
else
{
// 移除 vite 内置的 css post 处理,交由 @dcloudio/uni-cli-shared 的 uniCssPlugin 实现
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
'
vite:css-post
'
)
if
(
index
>
-
1
)
{
;(
config
.
plugins
as
Plugin
[]).
splice
(
index
,
1
)
}
removePlugins
([
'
vite:css-post
'
],
config
)
}
}
function
initCodeSpliting
(
config
:
ResolvedConfig
)
{
// 替换内置插件
const
replacedPlugins
=
[
assetPlugin
(
config
),
cssPlugin
(
config
),
cssPostPlugin
(
config
),
]
replacedPlugins
.
forEach
((
plugin
)
=>
{
const
index
=
(
config
.
plugins
as
Plugin
[]).
findIndex
(
(
p
)
=>
p
.
name
===
plugin
.
name
)
if
(
index
>
-
1
)
{
;(
config
.
plugins
as
Plugin
[]).
splice
(
index
,
1
,
plugin
)
}
})
const
removedPlugins
=
[
'
vite:import-analysis
'
]
removedPlugins
.
forEach
((
name
)
=>
{
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
name
)
if
(
index
>
-
1
)
{
;(
config
.
plugins
as
Plugin
[]).
splice
(
index
,
1
)
}
})
removePlugins
(
'
vite:import-analysis
'
,
config
)
injectAssetAndCssPlugins
(
config
)
}
packages/uni-cli-nvue/package.json
浏览文件 @
dbea30e6
...
...
@@ -52,7 +52,7 @@
"vue-hot-reload-api"
:
"^2.3.0"
,
"vue-style-loader"
:
"^4.1.0"
,
"vue-template-es2015-compiler"
:
"^1.9.0"
,
"webpack"
:
"
^
5.45.1"
,
"webpack"
:
"
~
5.45.1"
,
"webpack-sources"
:
"^3.1.2"
},
"devDependencies"
:
{
...
...
packages/uni-cli-shared/src/vite/utils/index.ts
浏览文件 @
dbea30e6
...
...
@@ -2,6 +2,7 @@ import { ResolvedConfig } from 'vite'
export
*
from
'
./ast
'
export
*
from
'
./url
'
export
*
from
'
./plugin
'
// 内置组件css列表,h5平台需要合并进去首页css中
export
const
buildInCssSet
=
new
Set
<
string
>
()
...
...
packages/uni-cli-shared/src/vite/utils/plugin.ts
浏览文件 @
dbea30e6
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
assetPlugin
}
from
'
../plugins/vitejs/plugins/asset
'
import
{
cssPlugin
,
cssPostPlugin
}
from
'
../plugins/vitejs/plugins/css
'
export
type
CreateUniViteFilterPlugin
=
(
opts
:
UniViteFilterPluginOptions
)
=>
Plugin
...
...
@@ -7,3 +8,36 @@ export interface UniViteFilterPluginOptions {
resolvedConfig
:
ResolvedConfig
filter
:
(
id
:
string
)
=>
boolean
}
export
function
injectAssetAndCssPlugins
(
config
:
ResolvedConfig
)
{
replacePlugins
(
[
assetPlugin
(
config
),
cssPlugin
(
config
),
cssPostPlugin
(
config
)],
config
)
}
export
function
replacePlugins
(
plugins
:
Plugin
[],
config
:
ResolvedConfig
)
{
plugins
.
forEach
((
plugin
)
=>
{
const
index
=
(
config
.
plugins
as
Plugin
[]).
findIndex
(
(
p
)
=>
p
.
name
===
plugin
.
name
)
if
(
index
>
-
1
)
{
;(
config
.
plugins
as
Plugin
[]).
splice
(
index
,
1
,
plugin
)
}
})
}
export
function
removePlugins
(
plugins
:
string
|
string
[],
config
:
ResolvedConfig
)
{
if
(
!
Array
.
isArray
(
plugins
))
{
plugins
=
[
plugins
]
}
plugins
.
forEach
((
name
)
=>
{
const
index
=
config
.
plugins
.
findIndex
((
p
)
=>
p
.
name
===
name
)
if
(
index
>
-
1
)
{
;(
config
.
plugins
as
Plugin
[]).
splice
(
index
,
1
)
}
})
}
tsconfig.json
浏览文件 @
dbea30e6
...
...
@@ -27,6 +27,7 @@
],
"rootDir"
:
"."
,
"paths"
:
{
"types/alias"
:
[
"packages/uni-cli-shared/types/alias.d.ts"
],
"@dcloudio/*"
:
[
"packages/*/src"
],
"@dcloudio/uni-platform"
:
[
"packages/uni-h5/src/platform/index.ts"
]
}
...
...
@@ -42,6 +43,7 @@
"test-dts"
,
"packages/uni-h5/types"
,
"packages/uni-app-vite/types"
,
"packages/uni-cli-shared/types"
,
"node_modules/mini-types/types/api/index.d.ts"
,
"node_modules/mini-types/types/page.d.ts"
,
"node_modules/mini-types/types/component.d.ts"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录