Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
erosXXX
uni-app
提交
b8e2c3ce
U
uni-app
项目概览
erosXXX
/
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,发现更多精彩内容 >>
提交
b8e2c3ce
编写于
9月 10, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app-plus-nvue): refactor style
上级
d881b8ce
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
488 addition
and
32 deletion
+488
-32
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+16
-4
packages/vue-cli-plugin-hbuilderx/module-alias.js
packages/vue-cli-plugin-hbuilderx/module-alias.js
+8
-1
packages/vue-cli-plugin-hbuilderx/packages/vue-loader/index.js
...ges/vue-cli-plugin-hbuilderx/packages/vue-loader/index.js
+211
-0
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/compileTemplate.js
...x/packages/webpack-uni-nvue-loader/lib/compileTemplate.js
+114
-0
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/main.js
...in-hbuilderx/packages/webpack-uni-nvue-loader/lib/main.js
+20
-17
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/styleInjection.js
...rx/packages/webpack-uni-nvue-loader/lib/styleInjection.js
+8
-9
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle.js
.../packages/webpack-uni-nvue-loader/lib/template.recycle.js
+18
-0
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/templateLoader.js
...rx/packages/webpack-uni-nvue-loader/lib/templateLoader.js
+92
-0
packages/vue-cli-plugin-hbuilderx/packages/weex-template-compiler/build.js
...plugin-hbuilderx/packages/weex-template-compiler/build.js
+1
-1
未找到文件。
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
b8e2c3ce
...
...
@@ -100,7 +100,7 @@ const rules = [{
{
test
:
/
\.
nvue
(\?[^
?
]
+
)?
$/
,
use
:
[{
loader
:
'
vue-loader
'
,
loader
:
path
.
resolve
(
__dirname
,
'
../packages/vue-loader
'
)
,
options
:
vueLoaderOptions
}],
exclude
:
excludeModuleReg
...
...
@@ -108,7 +108,7 @@ const rules = [{
{
test
:
/
\.
vue
(\?[^
?
]
+
)?
$/
,
use
:
[{
loader
:
'
vue-loader
'
,
loader
:
path
.
resolve
(
__dirname
,
'
../packages/vue-loader
'
)
,
options
:
vueLoaderOptions
}],
exclude
:
excludeModuleReg
...
...
@@ -146,6 +146,15 @@ if (process.env.UNI_USING_NVUE_COMPILER) {
}]
})
}
rules
.
unshift
({
resourceQuery
:
function
(
query
)
{
return
query
.
indexOf
(
'
vue&type=template
'
)
!==
-
1
&&
query
.
indexOf
(
'
mpType=page
'
)
===
-
1
},
use
:
[{
loader
:
'
@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle
'
}]
})
if
(
process
.
env
.
UNI_USING_NATIVE
)
{
plugins
.
push
(
new
WebpackUniMPPlugin
())
plugins
.
push
(
new
CopyWebpackPlugin
([{
...
...
@@ -185,7 +194,7 @@ module.exports = function () {
'
vue
'
:
'
Vue
'
},
optimization
:
{
namedModules
:
false
namedModules
:
false
},
output
:
{
path
:
process
.
env
.
UNI_OUTPUT_DIR
,
...
...
@@ -198,6 +207,9 @@ module.exports = function () {
'
@
'
:
process
.
env
.
UNI_INPUT_DIR
,
'
uni-pages
'
:
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json
'
),
'
@dcloudio/uni-stat
'
:
require
.
resolve
(
'
@dcloudio/uni-stat
'
),
'
uni-app-style
'
:
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
getNVueMainEntry
())
+
'
?
'
+
JSON
.
stringify
({
type
:
'
appStyle
'
}),
'
uni-stat-config
'
:
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
pages.json
'
)
+
'
?
'
+
JSON
.
stringify
({
...
...
@@ -205,7 +217,7 @@ module.exports = function () {
})
},
modules
:
[
'
node_modules
'
,
'
node_modules
'
,
path
.
resolve
(
process
.
env
.
UNI_CLI_CONTEXT
,
'
node_modules
'
),
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
node_modules
'
)
]
...
...
packages/vue-cli-plugin-hbuilderx/module-alias.js
浏览文件 @
b8e2c3ce
...
...
@@ -9,9 +9,16 @@ const {
// override
moduleAlias
.
addAlias
(
'
weex-styler
'
,
path
.
resolve
(
__dirname
,
'
packages/weex-styler
'
))
moduleAlias
.
addAlias
(
'
weex-template-compiler
'
,
path
.
resolve
(
__dirname
,
'
packages/weex-template-compiler
'
))
moduleAlias
.
addAlias
(
'
./compileTemplate
'
,
path
.
resolve
(
__dirname
,
'
packages/webpack-uni-nvue-loader/lib/compileTemplate
'
))
moduleAlias
.
addAlias
(
'
./codegen/styleInjection
'
,
path
.
resolve
(
__dirname
,
'
packages/webpack-uni-nvue-loader/lib/styleInjection
'
))
moduleAlias
.
addAlias
(
'
./templateLoader
'
,
(
fromPath
,
request
,
alias
)
=>
{
if
(
fromPath
.
indexOf
(
'
vue-loader
'
)
!==
-
1
)
{
return
path
.
resolve
(
__dirname
,
'
packages/webpack-uni-nvue-loader/lib/templateLoader
'
)
}
return
request
})
if
(
isInHBuilderX
)
{
moduleAlias
.
addAlias
(
'
typescript
'
,
path
.
resolve
(
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
'
compile-typescript/node_modules/typescript
'
))
...
...
packages/vue-cli-plugin-hbuilderx/packages/vue-loader/index.js
0 → 100644
浏览文件 @
b8e2c3ce
const
path
=
require
(
'
path
'
)
const
hash
=
require
(
'
hash-sum
'
)
const
qs
=
require
(
'
querystring
'
)
const
plugin
=
require
(
'
vue-loader/lib/plugin
'
)
const
selectBlock
=
require
(
'
vue-loader/lib/select
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
{
attrsToQuery
}
=
require
(
'
vue-loader/lib/codegen/utils
'
)
const
{
parse
}
=
require
(
'
@vue/component-compiler-utils
'
)
const
genStylesCode
=
require
(
'
../webpack-uni-nvue-loader/lib/styleInjection
'
)
const
{
genHotReloadCode
}
=
require
(
'
vue-loader/lib/codegen/hotReload
'
)
const
genCustomBlocksCode
=
require
(
'
vue-loader/lib/codegen/customBlocks
'
)
const
componentNormalizerPath
=
require
.
resolve
(
'
vue-loader/lib/runtime/componentNormalizer
'
)
const
{
NS
}
=
require
(
'
vue-loader/lib/plugin
'
)
let
errorEmitted
=
false
function
loadTemplateCompiler
(
loaderContext
)
{
try
{
return
require
(
'
vue-template-compiler
'
)
}
catch
(
e
)
{
if
(
/version mismatch/
.
test
(
e
.
toString
()))
{
loaderContext
.
emitError
(
e
)
}
else
{
loaderContext
.
emitError
(
new
Error
(
`[vue-loader] vue-template-compiler must be installed as a peer dependency, `
+
`or a compatible compiler implementation must be passed via options.`
))
}
}
}
function
hasRecyclable
(
template
)
{
return
!!
(
template
&&
template
.
attrs
&&
template
.
attrs
.
recyclable
)
}
module
.
exports
=
function
(
source
)
{
const
loaderContext
=
this
if
(
!
errorEmitted
&&
!
loaderContext
[
'
thread-loader
'
]
&&
!
loaderContext
[
NS
])
{
loaderContext
.
emitError
(
new
Error
(
`vue-loader was used without the corresponding plugin. `
+
`Make sure to include VueLoaderPlugin in your webpack config.`
))
errorEmitted
=
true
}
const
stringifyRequest
=
r
=>
loaderUtils
.
stringifyRequest
(
loaderContext
,
r
)
const
{
target
,
request
,
minimize
,
sourceMap
,
rootContext
,
resourcePath
,
resourceQuery
}
=
loaderContext
const
rawQuery
=
resourceQuery
.
slice
(
1
)
const
inheritQuery
=
`&
${
rawQuery
}
`
const
incomingQuery
=
qs
.
parse
(
rawQuery
)
const
options
=
loaderUtils
.
getOptions
(
loaderContext
)
||
{}
const
isServer
=
target
===
'
node
'
const
isShadow
=
!!
options
.
shadowMode
const
isProduction
=
options
.
productionMode
||
minimize
||
process
.
env
.
NODE_ENV
===
'
production
'
const
filename
=
path
.
basename
(
resourcePath
)
const
context
=
rootContext
||
process
.
cwd
()
const
sourceRoot
=
path
.
dirname
(
path
.
relative
(
context
,
resourcePath
))
const
descriptor
=
parse
({
source
,
compiler
:
options
.
compiler
||
loadTemplateCompiler
(
loaderContext
),
filename
,
sourceRoot
,
needMap
:
sourceMap
})
// if the query has a type field, this is a language block request
// e.g. foo.vue?type=template&id=xxxxx
// and we will return early
if
(
incomingQuery
.
type
)
{
return
selectBlock
(
descriptor
,
loaderContext
,
incomingQuery
,
!!
options
.
appendExtension
)
}
// module id for scoped CSS & hot-reload
const
rawShortFilePath
=
path
.
relative
(
context
,
resourcePath
)
.
replace
(
/^
(\.\.[\/\\])
+/
,
''
)
const
shortFilePath
=
rawShortFilePath
.
replace
(
/
\\
/g
,
'
/
'
)
+
resourceQuery
const
id
=
hash
(
isProduction
?
(
shortFilePath
+
'
\n
'
+
source
)
:
shortFilePath
)
// feature information
const
hasScoped
=
descriptor
.
styles
.
some
(
s
=>
s
.
scoped
)
const
hasFunctional
=
descriptor
.
template
&&
descriptor
.
template
.
attrs
.
functional
const
needsHotReload
=
(
!
isServer
&&
!
isProduction
&&
(
descriptor
.
script
||
descriptor
.
template
)
&&
options
.
hotReload
!==
false
)
// template
let
templateImport
=
`var render, staticRenderFns`
let
templateRequest
const
recyclable
=
hasRecyclable
(
descriptor
.
template
)
// fixed by xxxxxx
if
(
descriptor
.
template
)
{
const
src
=
descriptor
.
template
.
src
||
resourcePath
const
idQuery
=
`&id=
${
id
}
`
const
scopedQuery
=
hasScoped
?
`&scoped=true`
:
``
const
attrsQuery
=
attrsToQuery
(
descriptor
.
template
.
attrs
)
const
query
=
`?vue&type=template
${
idQuery
}${
scopedQuery
}${
attrsQuery
}${
inheritQuery
}
`
const
request
=
templateRequest
=
stringifyRequest
(
src
+
query
)
if
(
recyclable
){
// fixed by xxxxxx
templateImport
=
`import { render, staticRenderFns, recyclableRender } from
${
request
}
`
}
else
{
templateImport
=
`import { render, staticRenderFns } from
${
request
}
`
}
}
// script
let
scriptImport
=
`var script = {}`
if
(
descriptor
.
script
)
{
const
src
=
descriptor
.
script
.
src
||
resourcePath
const
attrsQuery
=
attrsToQuery
(
descriptor
.
script
.
attrs
,
'
js
'
)
const
query
=
`?vue&type=script
${
attrsQuery
}${
inheritQuery
}
`
const
request
=
stringifyRequest
(
src
+
query
)
scriptImport
=
(
`import script from
${
request
}
\n`
+
`export * from
${
request
}
`
// support named exports
)
}
// styles
let
stylesCode
=
``
if
(
descriptor
.
styles
.
length
)
{
stylesCode
=
genStylesCode
(
loaderContext
,
descriptor
.
styles
,
id
,
resourcePath
,
stringifyRequest
,
needsHotReload
,
isServer
||
isShadow
// needs explicit injection?
)
}
let
code
=
`
${
templateImport
}
${
scriptImport
}
${
stylesCode
}
/* normalize component */
import normalizer from
${
stringifyRequest
(
`!
${
componentNormalizerPath
}
`
)}
var component = normalizer(
script,
render,
staticRenderFns,
${
hasFunctional
?
`true`
:
`false`
}
,
${
`null`
}
,
${
hasScoped
?
JSON
.
stringify
(
id
)
:
`null`
}
,
${
isServer
?
JSON
.
stringify
(
hash
(
request
))
:
`null`
}
${
isShadow
?
`,true`
:
``
}
)
`
.
trim
()
+
`\n`
if
(
descriptor
.
customBlocks
&&
descriptor
.
customBlocks
.
length
)
{
code
+=
genCustomBlocksCode
(
descriptor
.
customBlocks
,
resourcePath
,
resourceQuery
,
stringifyRequest
)
}
if
(
needsHotReload
)
{
code
+=
`\n`
+
genHotReloadCode
(
id
,
hasFunctional
,
templateRequest
)
}
if
(
/injectStyles/
.
test
(
stylesCode
)){
// fixed by xxxxxx
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
// from the devtools.
code
+=
`\ncomponent.options.__file =
${
JSON
.
stringify
(
rawShortFilePath
.
replace
(
/
\\
/g
,
'
/
'
))}
`
}
else
if
(
options
.
exposeFilename
)
{
// Libraies can opt-in to expose their components' filenames in production builds.
// For security reasons, only expose the file's basename in production.
code
+=
`\ncomponent.options.__file =
${
JSON
.
stringify
(
filename
)}
`
}
if
(
recyclable
){
code
+=
`\nrecyclableRender && (component.options["@render"] = recyclableRender)`
// fixed by xxxxxx
}
code
+=
`\nexport default component.exports`
// console.log(code)
return
code
}
module
.
exports
.
VueLoaderPlugin
=
plugin
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/compileTemplate.js
0 → 100644
浏览文件 @
b8e2c3ce
"
use strict
"
;
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
const
assetUrl_1
=
__importDefault
(
require
(
"
@vue/component-compiler-utils/dist/templateCompilerModules/assetUrl
"
));
const
srcset_1
=
__importDefault
(
require
(
"
@vue/component-compiler-utils/dist/templateCompilerModules/srcset
"
));
const
consolidate
=
require
(
'
consolidate
'
);
const
transpile
=
require
(
'
vue-template-es2015-compiler
'
);
function
compileTemplate
(
options
)
{
const
{
preprocessLang
}
=
options
;
const
preprocessor
=
preprocessLang
&&
consolidate
[
preprocessLang
];
if
(
preprocessor
)
{
return
actuallyCompile
(
Object
.
assign
({},
options
,
{
source
:
preprocess
(
options
,
preprocessor
)
}));
}
else
if
(
preprocessLang
)
{
return
{
code
:
`var render = function () {}\n`
+
`var staticRenderFns = []\n`
,
source
:
options
.
source
,
tips
:
[
`Component
${
options
.
filename
}
uses lang
${
preprocessLang
}
for template. Please install the language preprocessor.`
],
errors
:
[
`Component
${
options
.
filename
}
uses lang
${
preprocessLang
}
for template, however it is not installed.`
]
};
}
else
{
return
actuallyCompile
(
options
);
}
}
exports
.
compileTemplate
=
compileTemplate
;
function
preprocess
(
options
,
preprocessor
)
{
const
{
source
,
filename
,
preprocessOptions
}
=
options
;
const
finalPreprocessOptions
=
Object
.
assign
({
filename
},
preprocessOptions
);
// Consolidate exposes a callback based API, but the callback is in fact
// called synchronously for most templating engines. In our case, we have to
// expose a synchronous API so that it is usable in Jest transforms (which
// have to be sync because they are applied via Node.js require hooks)
let
res
,
err
;
preprocessor
.
render
(
source
,
finalPreprocessOptions
,
(
_err
,
_res
)
=>
{
if
(
_err
)
err
=
_err
;
res
=
_res
;
});
if
(
err
)
throw
err
;
return
res
;
}
function
actuallyCompile
(
options
)
{
const
{
source
,
compiler
,
compilerOptions
=
{},
transpileOptions
=
{},
transformAssetUrls
,
isProduction
=
process
.
env
.
NODE_ENV
===
'
production
'
,
isFunctional
=
false
,
optimizeSSR
=
false
,
prettify
=
true
}
=
options
;
const
compile
=
optimizeSSR
&&
compiler
.
ssrCompile
?
compiler
.
ssrCompile
:
compiler
.
compile
;
let
finalCompilerOptions
=
compilerOptions
;
if
(
transformAssetUrls
)
{
const
builtInModules
=
[
transformAssetUrls
===
true
?
assetUrl_1
.
default
()
:
assetUrl_1
.
default
(
transformAssetUrls
),
srcset_1
.
default
()
];
finalCompilerOptions
=
Object
.
assign
({},
compilerOptions
,
{
modules
:
[...
builtInModules
,
...(
compilerOptions
.
modules
||
[])]
});
}
const
{
render
,
staticRenderFns
,
tips
,
errors
,
'
@render
'
:
recyclableRender
}
=
compile
(
source
,
finalCompilerOptions
);
if
(
errors
&&
errors
.
length
)
{
return
{
code
:
`var render = function () {}\n`
+
`var staticRenderFns = []\n`
,
source
,
tips
,
errors
};
}
else
{
const
finalTranspileOptions
=
Object
.
assign
({},
transpileOptions
,
{
transforms
:
Object
.
assign
({},
transpileOptions
.
transforms
,
{
stripWithFunctional
:
isFunctional
})
});
const
toFunction
=
(
code
)
=>
{
return
`function (
${
isFunctional
?
`_h,_vm`
:
``
}
) {
${
code
}
}`
;
};
// transpile code with vue-template-es2015-compiler, which is a forked
// version of Buble that applies ES2015 transforms + stripping `with` usage
let
code
=
transpile
(
`var __render__ =
${
toFunction
(
render
)}
\n`
+
(
recyclableRender
?
(
`var __recyclableRender__ =
${
toFunction
(
recyclableRender
)}
\n`
)
:
''
)
+
`var __staticRenderFns__ = [
${
staticRenderFns
.
map
(
toFunction
)}
]`
,
finalTranspileOptions
)
+
`\n`
;
// #23 we use __render__ to avoid `render` not being prefixed by the
// transpiler when stripping with, but revert it back to `render` to
// maintain backwards compat
code
=
code
.
replace
(
/
\s
__
(
render|recyclableRender|staticRenderFns
)
__
\s
/g
,
'
$1
'
);
if
(
!
isProduction
)
{
// mark with stripped (this enables Vue to use correct runtime proxy
// detection)
code
+=
`render._withStripped = true`
;
if
(
prettify
)
{
code
=
require
(
'
prettier
'
).
format
(
code
,
{
semi
:
false
,
parser
:
'
babel
'
});
}
}
return
{
code
,
source
,
tips
,
errors
};
}
}
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/main.js
浏览文件 @
b8e2c3ce
...
...
@@ -28,7 +28,7 @@ function getAppStyleCode(stringifyRequest) {
if
(
!
process
.
env
.
UNI_USING_NVUE_COMPILER
)
{
return
''
}
let
code
=
'
App.appStyle
= {}
\n
'
let
code
=
'
Vue.prototype.__$appStyle__
= {}
\n
'
let
styles
=
[]
try
{
if
(
fs
.
existsSync
(
appVuePath
))
{
...
...
@@ -37,7 +37,7 @@ function getAppStyleCode(stringifyRequest) {
}
catch
(
e
)
{}
styles
.
forEach
((
style
,
index
)
=>
{
code
=
code
+
`Vue.prototype.__merge_style(require(
${
genStyleRequest
(
style
,
index
,
stringifyRequest
)}
).default,
App.appStyle
)\n`
`Vue.prototype.__merge_style(require(
${
genStyleRequest
(
style
,
index
,
stringifyRequest
)}
).default,
Vue.prototype.__$appStyle__
)\n`
})
return
code
}
...
...
@@ -51,22 +51,25 @@ module.exports = function(content) {
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
params
&&
params
.
page
)
{
const
stringifyRequest
=
r
=>
loaderUtils
.
stringifyRequest
(
loaderContext
,
r
)
params
.
page
=
decodeURIComponent
(
params
.
page
)
// import Vue from 'vue'是为了触发 vendor 合并
return
`
${
statCode
}
import App from './
${
normalizePath
(
params
.
page
)}
.nvue?mpType=page'
App.mpType = 'page'
App.route = '
${
params
.
page
}
'
App.el = '#root'
${
getAppStyleCode
(
stringifyRequest
)}
new Vue(App)
`
if
(
params
)
{
if
(
params
.
page
)
{
params
.
page
=
decodeURIComponent
(
params
.
page
)
// import Vue from 'vue'是为了触发 vendor 合并
return
`
${
statCode
}
import 'uni-app-style'
import App from './
${
normalizePath
(
params
.
page
)}
.nvue?mpType=page'
App.mpType = 'page'
App.route = '
${
params
.
page
}
'
App.el = '#root'
new Vue(App)
`
}
else
if
(
params
.
type
===
'
appStyle
'
)
{
const
stringifyRequest
=
r
=>
loaderUtils
.
stringifyRequest
(
loaderContext
,
r
)
return
`
${
getAppStyleCode
(
stringifyRequest
)}
`
}
}
}
return
statCode
+
content
}
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/styleInjection.js
浏览文件 @
b8e2c3ce
...
...
@@ -86,21 +86,21 @@ module.exports = function genStyleInjectionCode (
}
})
}
else
{
styleInjectionCode
=
`if(!this.
$
options.style){
this.
$
options.style = {}
styleInjectionCode
=
`if(!this.options.style){
this.options.style = {}
}
if(
this.__merge_style && this.$root && this.$root.$options.appStyle
){
this.__merge_style(this.$root.$options.appS
tyle)
if(
Vue.prototype.__merge_style && Vue.prototype.__$appStyle__
){
Vue.prototype.__merge_style(Vue.prototype.__$appStyle__, this.options.s
tyle)
}
`
styles
.
forEach
((
style
,
i
)
=>
{
if
(
isNotEmptyStyle
(
style
))
{
const
request
=
genStyleRequest
(
style
,
i
)
styleInjectionCode
+=
(
`if(
this
.__merge_style){
this.__merge_style(require(
${
request
}
).default
)
`if(
Vue.prototype
.__merge_style){
Vue.prototype.__merge_style(require(
${
request
}
).default, this.options.style
)
}else{
Object.assign(this.
$
options.style,require(
${
request
}
).default)
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`
...
...
@@ -119,8 +119,7 @@ ${styleImportsCode}
${
hasCSSModules
&&
needsHotReload
?
`var cssModules = {}`
:
``
}
${
needsHotReload
?
`var disposed = false`
:
``
}
function injectStyles (context) {
${
needsHotReload
?
`if (disposed) return`
:
``
}
function injectStyles () {
${
styleInjectionCode
}
}
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle.js
0 → 100644
浏览文件 @
b8e2c3ce
const
loaderUtils
=
require
(
'
loader-utils
'
)
module
.
exports
=
function
(
content
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
vueLoaderOptions
=
this
.
loaders
[
0
]
if
(
vueLoaderOptions
.
ident
===
'
vue-loader-options
'
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
params
.
recyclable
)
{
Object
.
assign
(
vueLoaderOptions
.
options
.
compilerOptions
,
{
recyclable
:
true
})
}
}
else
{
throw
new
Error
(
'
vue-loader-options parse error
'
)
}
return
content
}
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/templateLoader.js
0 → 100644
浏览文件 @
b8e2c3ce
const
qs
=
require
(
'
querystring
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
{
compileTemplate
}
=
require
(
'
@vue/component-compiler-utils
'
)
// Loader that compiles raw template into JavaScript functions.
// This is injected by the global pitcher (../pitch) for template
// selection requests initiated from vue files.
module
.
exports
=
function
(
source
)
{
const
loaderContext
=
this
const
query
=
qs
.
parse
(
this
.
resourceQuery
.
slice
(
1
))
// although this is not the main vue-loader, we can get access to the same
// vue-loader options because we've set an ident in the plugin and used that
// ident to create the request for this loader in the pitcher.
const
options
=
loaderUtils
.
getOptions
(
loaderContext
)
||
{}
const
{
id
}
=
query
const
isServer
=
loaderContext
.
target
===
'
node
'
const
isProduction
=
options
.
productionMode
||
loaderContext
.
minimize
||
process
.
env
.
NODE_ENV
===
'
production
'
const
isFunctional
=
query
.
functional
// allow using custom compiler via options
const
compiler
=
options
.
compiler
||
require
(
'
vue-template-compiler
'
)
const
compilerOptions
=
Object
.
assign
({
outputSourceRange
:
true
},
options
.
compilerOptions
,
{
scopeId
:
query
.
scoped
?
`data-v-
${
id
}
`
:
null
,
comments
:
query
.
comments
})
// for vue-component-compiler
const
finalOptions
=
{
source
,
filename
:
this
.
resourcePath
,
compiler
,
compilerOptions
,
// allow customizing behavior of vue-template-es2015-compiler
transpileOptions
:
options
.
transpileOptions
,
transformAssetUrls
:
options
.
transformAssetUrls
||
true
,
isProduction
,
isFunctional
,
optimizeSSR
:
isServer
&&
options
.
optimizeSSR
!==
false
,
prettify
:
options
.
prettify
}
const
compiled
=
compileTemplate
(
finalOptions
)
// tips
if
(
compiled
.
tips
&&
compiled
.
tips
.
length
)
{
compiled
.
tips
.
forEach
(
tip
=>
{
loaderContext
.
emitWarning
(
typeof
tip
===
'
object
'
?
tip
.
msg
:
tip
)
})
}
// errors
if
(
compiled
.
errors
&&
compiled
.
errors
.
length
)
{
// 2.6 compiler outputs errors as objects with range
if
(
compiler
.
generateCodeFrame
&&
finalOptions
.
compilerOptions
.
outputSourceRange
)
{
// TODO account for line offset in case template isn't placed at top
// of the file
loaderContext
.
emitError
(
`\n\n Errors compiling template:\n\n`
+
compiled
.
errors
.
map
(({
msg
,
start
,
end
})
=>
{
const
frame
=
compiler
.
generateCodeFrame
(
source
,
start
,
end
)
return
`
${
msg
}
\n\n
${
pad
(
frame
)}
`
}).
join
(
`\n\n`
)
+
'
\n
'
)
}
else
{
loaderContext
.
emitError
(
`\n Error compiling template:\n
${
pad
(
compiled
.
source
)}
\n`
+
compiled
.
errors
.
map
(
e
=>
` -
${
e
}
`
).
join
(
'
\n
'
)
+
'
\n
'
)
}
}
const
{
code
}
=
compiled
if
(
query
.
recyclable
)
{
// fixed by xxxxxx
return
code
+
`\nexport { render, recyclableRender, staticRenderFns }`
}
// finish with ESM exports
return
code
+
`\nexport { render, staticRenderFns }`
}
function
pad
(
source
)
{
return
source
.
split
(
/
\r?\n
/
)
.
map
(
line
=>
`
${
line
}
`
)
.
join
(
'
\n
'
)
}
packages/vue-cli-plugin-hbuilderx/packages/weex-template-compiler/build.js
浏览文件 @
b8e2c3ce
...
...
@@ -4683,7 +4683,7 @@ function postTransformComponentRoot (el) {
/* */
function
postTransformRef
(
el
,
options
)
{
function
postTransformRef
(
el
)
{
if
(
el
.
ref
)
{
addAttr
(
el
,
'
ref
'
,
el
.
ref
);
delete
el
.
ref
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录