Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
cc34062c
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,发现更多精彩内容 >>
提交
cc34062c
编写于
7月 29, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(app): vue-loader
上级
27387af1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
17 deletion
+38
-17
packages/uni-cli-nvue/dist/webpack/config/module/rules/vueLoader.js
...ni-cli-nvue/dist/webpack/config/module/rules/vueLoader.js
+1
-0
packages/uni-cli-nvue/lib/vue-loader/lib/codegen/styleInjection.js
...uni-cli-nvue/lib/vue-loader/lib/codegen/styleInjection.js
+11
-3
packages/uni-cli-nvue/lib/vue-loader/lib/index.js
packages/uni-cli-nvue/lib/vue-loader/lib/index.js
+20
-9
packages/uni-cli-nvue/lib/vue-loader/lib/loaders/templateLoader.js
...uni-cli-nvue/lib/vue-loader/lib/loaders/templateLoader.js
+5
-5
packages/uni-cli-nvue/src/webpack/config/module/rules/vueLoader.ts
...uni-cli-nvue/src/webpack/config/module/rules/vueLoader.ts
+1
-0
未找到文件。
packages/uni-cli-nvue/dist/webpack/config/module/rules/vueLoader.js
浏览文件 @
cc34062c
...
...
@@ -7,6 +7,7 @@ exports.vueLoader = {
{
loader
:
'
vue-loader
'
,
options
:
{
hotReload
:
false
,
compiler
:
require
(
'
../../../../../lib/weex-template-compiler
'
),
},
},
...
...
packages/uni-cli-nvue/lib/vue-loader/lib/codegen/styleInjection.js
浏览文件 @
cc34062c
...
...
@@ -85,13 +85,21 @@ module.exports = function genStyleInjectionCode (
if
(
style
.
module
)
genCSSModulesCode
(
style
,
request
,
i
)
}
})
}
else
{
}
else
{
// fixed by xxxxxx nvue style
styleInjectionCode
=
`if(!this.options.style){this.options.style = {}}
if(Vue.prototype.__merge_style && Vue.prototype.__$appStyle__){Vue.prototype.__merge_style(Vue.prototype.__$appStyle__, this.options.style)}
`
styles
.
forEach
((
style
,
i
)
=>
{
if
(
isNotEmptyStyle
(
style
))
{
const
request
=
genStyleRequest
(
style
,
i
)
styleInjectionCode
+=
(
`var style
${
i
}
= require(
${
request
}
)\n`
+
`if (style
${
i
}
.__inject__) style
${
i
}
.__inject__(context)\n`
`if(Vue.prototype.__merge_style){
Vue.prototype.__merge_style(require(
${
request
}
).default, this.options.style)
}else{
Object.assign(this.options.style,require(
${
request
}
).default)
}\n`
//fixed by xxxxxx 简单处理,与 weex-vue-loader 保持一致
//`var style${i} = require(${request})\n` +
//`if (style${i}.__inject__) style${i}.__inject__(context)\n`
)
if
(
style
.
module
)
genCSSModulesCode
(
style
,
request
,
i
)
}
...
...
packages/uni-cli-nvue/lib/vue-loader/lib/index.js
浏览文件 @
cc34062c
...
...
@@ -110,6 +110,9 @@ module.exports = function (source) {
// template
let
templateImport
=
`var render, staticRenderFns`
let
templateRequest
// fixed by xxxxxx (recyclable,auto components)
templateImport
+=
`, recyclableRender, components`
const
recyclable
=
descriptor
.
template
&&
!!
(
template
.
attrs
&&
template
.
attrs
.
recyclable
)
if
(
descriptor
.
template
)
{
const
src
=
descriptor
.
template
.
src
||
resourcePath
const
idQuery
=
`&id=
${
id
}
`
...
...
@@ -117,7 +120,9 @@ module.exports = function (source) {
const
attrsQuery
=
attrsToQuery
(
descriptor
.
template
.
attrs
)
const
query
=
`?vue&type=template
${
idQuery
}${
scopedQuery
}${
attrsQuery
}${
inheritQuery
}
`
const
request
=
templateRequest
=
stringifyRequest
(
src
+
query
)
templateImport
=
`import { render, staticRenderFns } from
${
request
}
`
// templateImport = `import { render, staticRenderFns } from ${request}`
// fixed by xxxxxx (auto components)
templateImport
=
`import { render, staticRenderFns, recyclableRender, components } from
${
request
}
`
}
// script
...
...
@@ -133,7 +138,7 @@ module.exports = function (source) {
)
}
// styles
// styles
fixed by xxxxxx
let
stylesCode
=
``
if
(
descriptor
.
styles
.
length
)
{
stylesCode
=
genStylesCode
(
...
...
@@ -143,10 +148,10 @@ module.exports = function (source) {
resourcePath
,
stringifyRequest
,
needsHotReload
,
isServer
||
isShadow
// needs explicit injection?
true
//
isServer || isShadow // needs explicit injection?
)
}
// fixed by xxxxxx (injectStyles,auto components)
let
code
=
`
${
templateImport
}
${
scriptImport
}
...
...
@@ -159,10 +164,11 @@ var component = normalizer(
render,
staticRenderFns,
${
hasFunctional
?
`true`
:
`false`
}
,
${
/
injectStyles
/
.
test
(
stylesCode
)
?
`injectStyles`
:
`null`
}
,
${
`null`
/* fixed by xxxxxx */
}
,
${
hasScoped
?
JSON
.
stringify
(
id
)
:
`null`
}
,
${
isServer
?
JSON
.
stringify
(
hash
(
request
))
:
`null`
}
${
isShadow
?
`,true`
:
``
}
${
isShadow
?
`,true`
:
``
}
,
components
)
`
.
trim
()
+
`\n`
...
...
@@ -174,11 +180,14 @@ var component = normalizer(
stringifyRequest
)
}
if
(
needsHotReload
)
{
code
+=
`\n`
+
genHotReloadCode
(
id
,
hasFunctional
,
templateRequest
)
}
// fixed by xxxxxx (app-nvue injectStyles)
if
(
/injectStyles/
.
test
(
stylesCode
))
{
code
+=
`\ninjectStyles.call(component)`
}
// Expose filename. This is used by the devtools and Vue runtime warnings.
if
(
!
isProduction
)
{
// Expose the file's full path in development, so that it can be opened
...
...
@@ -189,7 +198,9 @@ var component = normalizer(
// For security reasons, only expose the file's basename in production.
code
+=
`\ncomponent.options.__file =
${
JSON
.
stringify
(
filename
)}
`
}
if
(
recyclable
)
{
// fixed by xxxxxx app-plus recyclable
code
+=
`\nrecyclableRender && (component.options["@render"] = recyclableRender)`
// fixed by xxxxxx
}
code
+=
`\nexport default component.exports`
return
code
}
...
...
packages/uni-cli-nvue/lib/vue-loader/lib/loaders/templateLoader.js
浏览文件 @
cc34062c
...
...
@@ -64,21 +64,21 @@ module.exports = function (source) {
const
frame
=
compiler
.
generateCodeFrame
(
source
,
start
,
end
)
return
`
${
msg
}
\n\n
${
pad
(
frame
)}
`
}).
join
(
`\n\n`
)
+
'
\n
'
'
\n
at
'
+
finalOptions
.
filename
+
'
:0
'
// fixed by xxxxxx
)
}
else
{
loaderContext
.
emitError
(
`\n Error compiling template:\n
${
pad
(
compiled
.
source
)}
\n`
+
compiled
.
errors
.
map
(
e
=>
` -
${
e
}
`
).
join
(
'
\n
'
)
+
'
\n
'
'
\n
at
'
+
finalOptions
.
filename
+
'
:0
'
// fixed by xxxxxx
)
}
}
const
{
code
}
=
compiled
// finish with ESM exports
return
code
+
`\nexport { render, staticRenderFns }`
// fixed by xxxxxx recyclableRender, components
// finish with ESM exports
return
code
+
`\nexport { render, staticRenderFns
, recyclableRender, components
}`
}
function
pad
(
source
)
{
...
...
packages/uni-cli-nvue/src/webpack/config/module/rules/vueLoader.ts
浏览文件 @
cc34062c
...
...
@@ -6,6 +6,7 @@ export const vueLoader: RuleSetRule = {
{
loader
:
'
vue-loader
'
,
options
:
{
hotReload
:
false
,
compiler
:
require
(
'
../../../../../lib/weex-template-compiler
'
),
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录