Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
bc6d5ef8
U
uni-app
项目概览
DCloud
/
uni-app
4 个月 前同步成功
通知
726
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bc6d5ef8
编写于
11月 06, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(v3): improve watch
上级
1c7f4755
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
99 addition
and
41 deletion
+99
-41
build/build.js
build/build.js
+5
-3
packages/uni-cli-shared/lib/platform.js
packages/uni-cli-shared/lib/platform.js
+10
-3
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
...lugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
+44
-4
packages/vue-cli-plugin-uni/lib/app-plus/index.js
packages/vue-cli-plugin-uni/lib/app-plus/index.js
+1
-1
packages/vue-cli-plugin-uni/lib/configure-webpack.js
packages/vue-cli-plugin-uni/lib/configure-webpack.js
+1
-1
packages/vue-cli-plugin-uni/lib/copy-webpack-options.js
packages/vue-cli-plugin-uni/lib/copy-webpack-options.js
+3
-2
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
...i-plugin-uni/packages/webpack-uni-app-loader/view/main.js
+1
-1
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+34
-26
未找到文件。
build/build.js
浏览文件 @
bc6d5ef8
...
...
@@ -27,9 +27,11 @@ if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_UI === 'true') {
entry
=
'
./lib/
'
+
process
.
env
.
UNI_PLATFORM
+
'
/ui.js
'
}
let
formats
=
process
.
env
.
UNI_WATCH
===
'
true
'
?
'
umd
'
:
'
umd-min
'
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
process
.
env
.
UNI_VIEW
===
'
true
'
)
{
name
=
'
uni
'
filename
=
'
view
'
formats
=
'
umd
'
entry
=
'
./lib/
'
+
process
.
env
.
UNI_PLATFORM
+
'
/view.js
'
}
service
.
run
(
'
build
'
,
{
...
...
@@ -37,11 +39,11 @@ service.run('build', {
filename
,
watch
:
process
.
env
.
UNI_WATCH
===
'
true
'
,
target
:
'
lib
'
,
formats
:
process
.
env
.
UNI_WATCH
===
'
true
'
?
'
umd
'
:
'
umd-min
'
,
formats
,
entry
,
clean
:
!
process
.
env
.
UNI_VIEW
,
mode
:
process
.
env
.
NODE_ENV
}).
then
(
function
()
{
}).
then
(
function
()
{
if
(
process
.
env
.
UNI_WATCH
!==
'
true
'
&&
process
.
env
.
UNI_UI
!==
'
true
'
&&
...
...
@@ -62,7 +64,7 @@ if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_WATCH === 'false') {
const
packageJsonPath
=
path
.
join
(
packagePath
,
'
package.json
'
)
del
(
path
.
join
(
packagePath
,
'
{lib,src}
'
))
.
then
(()
=>
{
copy
([
path
.
join
(
__dirname
,
'
../{lib,src}/**/*
'
)],
packagePath
,
function
(
err
,
file
)
{
copy
([
path
.
join
(
__dirname
,
'
../{lib,src}/**/*
'
)],
packagePath
,
function
(
err
,
file
)
{
if
(
err
)
{
throw
err
}
...
...
packages/uni-cli-shared/lib/platform.js
浏览文件 @
bc6d5ef8
...
...
@@ -129,8 +129,16 @@ const PLATFORMS = {
'
--window-bottom
'
:
'
0px
'
},
copyWebpackOptions
({
assetsDir
assetsDir
,
vueOptions
})
{
if
(
vueOptions
.
pluginOptions
[
'
uni-app-plus
'
]
&&
vueOptions
.
pluginOptions
[
'
uni-app-plus
'
][
'
view
'
]
)
{
// app-view 无需拷贝资源(app-service 已经做了)
return
[]
}
const
files
=
[
'
hybrid/html
'
]
let
wxcomponents
=
[]
if
(
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3
)
{
...
...
@@ -143,7 +151,6 @@ const PLATFORMS = {
if
(
process
.
env
.
UNI_USING_V3
)
{
view
=
getCopyOptions
([
require
.
resolve
(
'
@dcloudio/uni-app-plus/dist/view.css
'
),
// TODO view.umd.min.js
require
.
resolve
(
'
@dcloudio/uni-app-plus/dist/view.umd.js
'
)
])
template
=
getCopyOptions
([
path
.
resolve
(
__dirname
,
'
../template
'
)])
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
浏览文件 @
bc6d5ef8
...
...
@@ -9,24 +9,64 @@ const {
let
serviceCompiled
=
true
let
viewCompiled
=
true
const
serviceChangedFiles
=
[]
const
viewChangedFiles
=
[]
let
isFirst
=
true
class
WebpackAppPlusPlugin
{
apply
(
compiler
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
const
chunkVersions
=
{}
const
isAppService
=
compiler
.
options
.
entry
[
'
app-service
'
]
const
isAppView
=
compiler
.
options
.
entry
[
'
app-view
'
]
compiler
.
hooks
.
beforeCompile
.
tapAsync
(
'
WebpackAppPlusPlugin
'
,
(
params
,
callback
)
=>
{
isAppService
&&
(
serviceCompiled
=
false
)
isAppView
&&
(
viewCompiled
=
false
)
callback
()
})
compiler
.
hooks
.
emit
.
tapAsync
(
'
WebpackAppPlusPlugin
'
,
(
compilation
,
callback
)
=>
{
isAppService
&&
(
serviceChangedFiles
.
length
=
0
)
isAppView
&&
(
viewChangedFiles
.
length
=
0
)
const
changedChunks
=
compilation
.
chunks
.
filter
(
chunk
=>
{
const
oldVersion
=
chunkVersions
[
chunk
.
name
]
chunkVersions
[
chunk
.
name
]
=
chunk
.
hash
return
chunk
.
hash
!==
oldVersion
})
changedChunks
.
map
(
chunk
=>
{
if
(
Array
.
isArray
(
chunk
.
files
))
{
chunk
.
files
.
forEach
(
file
=>
{
if
(
isAppService
)
{
!
serviceChangedFiles
.
includes
(
file
)
&&
(
serviceChangedFiles
.
push
(
file
))
}
else
if
(
isAppView
)
{
!
viewChangedFiles
.
includes
(
file
)
&&
(
viewChangedFiles
.
push
(
file
))
}
})
}
})
callback
()
})
compiler
.
hooks
.
done
.
tapPromise
(
'
WebpackAppPlusPlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
isAppService
&&
(
serviceCompiled
=
true
)
isAppView
&&
(
viewCompiled
=
true
)
if
(
serviceCompiled
&&
viewCompiled
)
{
const
changedFiles
=
[...
new
Set
([...
serviceChangedFiles
,
...
viewChangedFiles
])]
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
if
(
!
isFirst
&&
changedFiles
.
length
>
0
)
{
done
(
`Build complete. FILES:`
+
JSON
.
stringify
(
changedFiles
))
}
else
{
done
(
`Build complete. Watching for changes...`
)
}
isFirst
=
false
}
else
{
done
(
`Build complete. `
)
}
...
...
packages/vue-cli-plugin-uni/lib/app-plus/index.js
浏览文件 @
bc6d5ef8
...
...
@@ -75,7 +75,7 @@ const v3 = {
return
{
devtool
,
mode
:
isAppView
?
'
production
'
:
process
.
env
.
NODE_ENV
,
mode
:
process
.
env
.
NODE_ENV
,
externals
:
{
vue
:
'
Vue
'
},
...
...
packages/vue-cli-plugin-uni/lib/configure-webpack.js
浏览文件 @
bc6d5ef8
...
...
@@ -174,7 +174,7 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
'
node_modules
'
)
const
plugins
=
[
new
CopyWebpackPlugin
(
getCopyWebpackPluginOptions
(
manifestPlatformOptions
))
new
CopyWebpackPlugin
(
getCopyWebpackPluginOptions
(
manifestPlatformOptions
,
vueOptions
))
]
if
(
process
.
UNI_SCRIPT_ENV
&&
Object
.
keys
(
process
.
UNI_SCRIPT_ENV
).
length
)
{
...
...
packages/vue-cli-plugin-uni/lib/copy-webpack-options.js
浏览文件 @
bc6d5ef8
const
assetsDir
=
'
static
'
function
getCopyWebpackPluginOptions
(
manifestPlatformOptions
)
{
function
getCopyWebpackPluginOptions
(
manifestPlatformOptions
,
vueOptions
)
{
const
{
getPlatformCopy
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
return
getPlatformCopy
()({
assetsDir
,
manifestPlatformOptions
manifestPlatformOptions
,
vueOptions
})
}
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
浏览文件 @
bc6d5ef8
...
...
@@ -93,7 +93,7 @@ function getStylesCode(loaderContext) {
module
.
exports
=
function
(
source
,
map
)
{
return
`
import 'uni-pages'
import 'uni-pages
?
${
JSON
.
stringify
({
type
:
'
view
'
})}
'
function initView(){
${
getStylesCode
(
this
)}
injectStyles()
...
...
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
bc6d5ef8
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
{
parsePages
,
normalizePath
,
...
...
@@ -32,6 +34,12 @@ function renameUsingComponents (jsonObj) {
module
.
exports
=
function
(
content
)
{
this
.
cacheable
&&
this
.
cacheable
()
let
isAppView
=
false
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
isAppView
=
params
.
type
===
'
view
'
}
const
pagesJsonJsPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
pagesJsonJsFileName
)
const
manifestJsonPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json
'
)
const
manifestJson
=
parseManifestJson
(
fs
.
readFileSync
(
manifestJsonPath
,
'
utf8
'
))
...
...
@@ -69,7 +77,7 @@ module.exports = function (content) {
const
jsonFiles
=
require
(
'
./platforms/
'
+
process
.
env
.
UNI_PLATFORM
)(
pagesJson
,
manifestJson
)
if
(
jsonFiles
&&
jsonFiles
.
length
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
if
(
process
.
env
.
UNI_USING_V3
&&
!
isAppView
)
{
// app-view 不需要生成 app-config-service.js,manifest.json
let
appConfigContent
=
''
jsonFiles
.
forEach
(
jsonFile
=>
{
if
(
jsonFile
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录