Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
Chameleon
提交
4d8cce14
C
Chameleon
项目概览
DiDi
/
Chameleon
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Chameleon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4d8cce14
编写于
4月 10, 2019
作者:
Y
yylgit
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mvvm-cml-loader
上级
4cf448d5
变更
24
展开全部
显示空白变更内容
内联
并排
Showing
24 changed file
with
1008 addition
and
73 deletion
+1008
-73
packages/chameleon-loader/src/helpers.js
packages/chameleon-loader/src/helpers.js
+0
-1
packages/chameleon-tool/chameleon.js
packages/chameleon-tool/chameleon.js
+1
-1
packages/chameleon-tool/commanders/extPlatform.js
packages/chameleon-tool/commanders/extPlatform.js
+7
-0
packages/chameleon-tool/commanders/utils.js
packages/chameleon-tool/commanders/utils.js
+20
-11
packages/chameleon-tool/configs/getCommonConfig.js
packages/chameleon-tool/configs/getCommonConfig.js
+3
-0
packages/chameleon-tool/configs/index.js
packages/chameleon-tool/configs/index.js
+32
-27
packages/chameleon-tool/configs/mvvm/extCmlLoader.js
packages/chameleon-tool/configs/mvvm/extCmlLoader.js
+70
-0
packages/chameleon-tool/configs/mvvm/getExtendConfig.js
packages/chameleon-tool/configs/mvvm/getExtendConfig.js
+46
-0
packages/chameleon-tool/configs/mvvm/utils.js
packages/chameleon-tool/configs/mvvm/utils.js
+1
-0
packages/chameleon-tool/configs/postcss/extend/.postcssrc.js
packages/chameleon-tool/configs/postcss/extend/.postcssrc.js
+7
-0
packages/chameleon-tool/configs/utils.js
packages/chameleon-tool/configs/utils.js
+16
-0
packages/chameleon-tool/lib/cli.js
packages/chameleon-tool/lib/cli.js
+14
-4
packages/chameleon-tool/npm-shrinkwrap.json
packages/chameleon-tool/npm-shrinkwrap.json
+10
-25
packages/chameleon-tool/package.json
packages/chameleon-tool/package.json
+2
-1
packages/chameleon-weex-vue-loader/lib/loader.js
packages/chameleon-weex-vue-loader/lib/loader.js
+2
-2
packages/chameleon-weex-vue-loader/lib/style-loader.js
packages/chameleon-weex-vue-loader/lib/style-loader.js
+1
-0
packages/interface-loader/src/index.js
packages/interface-loader/src/index.js
+0
-1
packages/mvvm-cml-loader/.eslintrc
packages/mvvm-cml-loader/.eslintrc
+566
-0
packages/mvvm-cml-loader/.gitignore
packages/mvvm-cml-loader/.gitignore
+68
-0
packages/mvvm-cml-loader/helper.js
packages/mvvm-cml-loader/helper.js
+42
-0
packages/mvvm-cml-loader/index.js
packages/mvvm-cml-loader/index.js
+48
-0
packages/mvvm-cml-loader/package.json
packages/mvvm-cml-loader/package.json
+15
-0
packages/mvvm-cml-loader/selector.js
packages/mvvm-cml-loader/selector.js
+36
-0
packages/mvvm-pack/lib/Compile.js
packages/mvvm-pack/lib/Compile.js
+1
-0
未找到文件。
packages/chameleon-loader/src/helpers.js
浏览文件 @
4d8cce14
...
...
@@ -117,7 +117,6 @@ module.exports = function createHelpers (
)
{
// console.log(fileType)
const
rawRequest
=
getRawRequest
(
loaderContext
,
options
.
excludedPreLoaders
)
const
{
defaultLoaders
,
loaders
,
...
...
packages/chameleon-tool/chameleon.js
浏览文件 @
4d8cce14
#! /usr/bin/env node
#! /usr/bin/env node
--inspect-brk
// --inspect-brk
require
(
'
./lib/index.js
'
);
...
...
packages/chameleon-tool/commanders/extPlatform.js
0 → 100644
浏览文件 @
4d8cce14
module
.
exports
=
function
({
type
,
media
})
{
const
utils
=
require
(
'
./utils.js
'
);
cml
.
media
=
media
;
utils
.
startReleaseOne
(
media
,
type
);
}
\ No newline at end of file
packages/chameleon-tool/commanders/utils.js
浏览文件 @
4d8cce14
...
...
@@ -20,6 +20,7 @@ exports.getBuildPromise = async function (media, type) {
if
(
~
[
'
wx
'
,
'
baidu
'
,
'
alipay
'
].
indexOf
(
type
))
{
// 异步删除output目录
var
outputpath
=
webpackConfig
.
output
.
path
;
if
(
outputpath
)
{
await
new
Promise
(
function
(
resolve
,
reject
)
{
fse
.
remove
(
outputpath
,
function
(
err
)
{
if
(
err
)
{
...
...
@@ -32,6 +33,7 @@ exports.getBuildPromise = async function (media, type) {
cml
.
log
.
error
(
message
);
throw
new
Error
(
e
)
})
}
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
...
@@ -73,6 +75,13 @@ exports.getBuildPromise = async function (media, type) {
* @param {*} type wx web weex
*/
exports
.
getOptions
=
function
(
media
,
type
)
{
if
(
!~
[
'
web
'
,
'
weex
'
,
'
alipay
'
,
'
baidu
'
,
'
wx
'
].
indexOf
(
type
))
{
return
{
type
:
type
,
media
,
root
:
cml
.
projectRoot
};
}
let
chameleonConfig
=
cml
.
config
.
get
()[
type
][
media
];
if
(
!
chameleonConfig
)
{
...
...
packages/chameleon-tool/configs/getCommonConfig.js
浏览文件 @
4d8cce14
...
...
@@ -33,6 +33,9 @@ module.exports = function (options) {
}
publicPath
=
options
.
publicPath
||
defaultPublichPathMap
[
type
];
if
(
!
publicPath
)
{
publicPath
=
`http://
${
config
.
ip
}
:
${
webServerPort
}
/
${
type
}
/`
}
let
commonConfig
=
{
...
...
packages/chameleon-tool/configs/index.js
浏览文件 @
4d8cce14
...
...
@@ -5,6 +5,7 @@ const getWeexDevConfig = require('./getWeexDevConfig.js');
const
getWeexBuildConfig
=
require
(
'
./getWeexBuildConfig.js
'
);
const
getMiniAppDevConfig
=
require
(
'
./getMiniAppDevConfig.js
'
);
const
getMiniAppBuildConfig
=
require
(
'
./getMiniAppBuildConfig.js
'
);
const
getExtendConfig
=
require
(
'
./mvvm/getExtendConfig.js
'
);
const
utils
=
require
(
'
./utils
'
);
/**
...
...
@@ -20,6 +21,10 @@ module.exports = async function (options) {
await
utils
.
setFreePort
();
let
{
type
,
media
}
=
options
;
let
webpackConfig
;
debugger
if
(
cml
.
config
.
get
().
extPlatform
&&
~
Object
.
keys
(
cml
.
config
.
get
().
extPlatform
).
indexOf
(
type
))
{
webpackConfig
=
getExtendConfig
(
options
);
}
else
{
switch
(
type
)
{
case
'
wx
'
:
case
'
alipay
'
:
...
...
@@ -45,9 +50,9 @@ module.exports = async function (options) {
}
break
;
default
:
break
;
}
}
cml
.
utils
.
applyPlugin
(
'
webpackConfig
'
,
{
type
,
media
,
webpackConfig
},
function
(
params
)
{
if
(
type
===
params
.
type
&&
media
===
params
.
media
)
{
...
...
packages/chameleon-tool/configs/mvvm/extCmlLoader.js
0 → 100644
浏览文件 @
4d8cce14
const
loaderUtils
=
require
(
'
loader-utils
'
)
module
.
exports
=
function
(
source
)
{
const
self
=
this
;
const
rawOptions
=
loaderUtils
.
getOptions
(
this
)
||
{};
const
context
=
(
this
.
rootContext
||
(
this
.
options
&&
this
.
options
.
context
)
||
process
.
cwd
()
)
function
getPartLoaders
(
part
)
{
let
loaders
=
self
.
loaders
.
map
(
loader
=>
{
let
loaderOptions
=
loader
.
options
||
{}
let
options
=
{
part
}
return
{
loader
:
loader
.
path
,
options
:
{
...
loaderOptions
,
...
options
}
}
})
let
stringLoaders
=
stringifyLoaders
(
loaders
);
let
resourcePath
=
self
.
resourcePath
;
return
'
!
'
+
stringLoaders
+
'
!
'
+
resourcePath
;
}
if
(
!
rawOptions
.
part
)
{
debugger
source
=
`
var template = require('
${
getPartLoaders
(
'
template
'
)}
');
var style = require('
${
getPartLoaders
(
'
style
'
)}
');
var json = require('
${
getPartLoaders
(
'
json
'
)}
');
var script = require('
${
getPartLoaders
(
'
script
'
)}
');
module.exports = {
template,
style,
json,
script
}
`
console
.
log
(
source
);
debugger
}
else
{
debugger
source
=
rawOptions
.
part
}
return
source
;
}
function
stringifyLoaders
(
loaders
)
{
return
loaders
.
map
(
obj
=>
obj
&&
typeof
obj
===
'
object
'
&&
typeof
obj
.
loader
===
'
string
'
?
obj
.
loader
+
(
obj
.
options
?
'
?
'
+
JSON
.
stringify
(
obj
.
options
)
:
''
)
:
obj
)
.
join
(
'
!
'
)
}
\ No newline at end of file
packages/chameleon-tool/configs/mvvm/getExtendConfig.js
0 → 100644
浏览文件 @
4d8cce14
const
merge
=
require
(
'
webpack-merge
'
)
const
path
=
require
(
'
path
'
);
// const cmlLoader = path.join(__dirname, './extCmlLoader.js');
const
getCommonConfig
=
require
(
'
../getCommonConfig
'
);
const
utils
=
require
(
'
../utils.js
'
);
module
.
exports
=
function
(
options
)
{
let
{
type
,
media
}
=
options
;
let
extendConfig
=
{
entry
:
{
app
:
path
.
join
(
cml
.
projectRoot
,
'
src/app/app.cml
'
)
},
output
:
{
path
:
path
.
join
(
cml
.
projectRoot
,
'
dist/
'
+
type
)
},
module
:
{
rules
:
[
...
utils
.
styleLoaders
({
type
}),
{
test
:
/
\.
cml$/
,
use
:
[{
loader
:
'
mvvm-cml-loader
'
,
options
:
{
loaders
:
utils
.
cssLoaders
({
type
,
media
}),
cmlType
:
type
,
media
,
check
:
cml
.
config
.
get
().
check
,
}
}]
}
]
},
plugins
:
[
{
apply
(
compiler
)
{
compiler
.
plugin
(
'
should-emit
'
,
function
(
compilation
)
{
debugger
})
}
}
]
};
return
merge
(
getCommonConfig
(
options
),
extendConfig
);
}
\ No newline at end of file
packages/chameleon-tool/configs/mvvm/utils.js
0 → 100644
浏览文件 @
4d8cce14
packages/chameleon-tool/configs/postcss/extend/.postcssrc.js
0 → 100644
浏览文件 @
4d8cce14
// https://github.com/michael-ciniawsky/postcss-load-config
module
.
exports
=
{
"
plugins
"
:
{
// to edit target browsers: use "browserslist" field in package.json
"
postcss-import
"
:
{},
}
}
\ No newline at end of file
packages/chameleon-tool/configs/utils.js
浏览文件 @
4d8cce14
...
...
@@ -63,6 +63,22 @@ exports.cssLoaders = function (options) {
// generate loader string to be used with extract text plugin
function
generateLoaders
(
loader
,
loaderOptions
)
{
// 扩展流程
if
(
cml
.
config
.
get
().
extPlatform
&&
~
Object
.
keys
(
cml
.
config
.
get
().
extPlatform
).
indexOf
(
options
.
type
))
{
let
extLoaders
=
[
getPostCssLoader
(
'
extend
'
),
{
loader
:
loader
+
'
-loader
'
,
options
:
Object
.
assign
({},
loaderOptions
,
{
sourceMap
:
false
})
}
]
addMediaLoader
(
extLoaders
,
options
.
type
);
return
extLoaders
;
}
var
loaders
=
[
cssLoader
];
let
result
=
[];
...
...
packages/chameleon-tool/lib/cli.js
浏览文件 @
4d8cce14
...
...
@@ -24,11 +24,21 @@ module.exports.run = function () {
// commanderInstance.registerCommander({commander: subCommander})
// })
// }
// 扩展端
const
extendPlatform
=
require
(
'
../commanders/extendPlatform.js
'
);
if
(
cml
.
config
.
get
().
platformPlugin
&&
cml
.
config
.
get
().
platformPlugin
[
first
])
{
extendPlatform
({
platform
:
first
,
media
:
argv
[
3
]});
}
else
{
// const extendPlatform = require('../commanders/extendPlatform.js');
// if (cml.config.get().platformPlugin && cml.config.get().platformPlugin[first]) {
// extendPlatform({platform: first, media: argv[3]});
// }
const
extPlatform
=
require
(
'
../commanders/extPlatform.js
'
);
if
(
cml
.
config
.
get
().
extPlatform
&&
~
Object
.
keys
(
cml
.
config
.
get
().
extPlatform
).
indexOf
(
first
))
{
extPlatform
({
type
:
first
,
media
:
argv
[
3
]});
}
else
{
commander
.
usage
(
'
[command] [options]
'
)
commander
.
version
(
`
${
cmlpackage
.
name
}
@
${
cmlpackage
.
version
}
`
)
let
cmdList
=
[
'
init
'
,
'
dev
'
,
'
build
'
,
'
server
'
,
'
web
'
,
'
weex
'
,
'
wx
'
,
'
baidu
'
,
'
alipay
'
];
...
...
packages/chameleon-tool/npm-shrinkwrap.json
浏览文件 @
4d8cce14
...
...
@@ -197,11 +197,6 @@
"@babel/types": "7.2.2"
}
},
"@babel/helper-plugin-utils": {
"version": "7.0.0",
"resolved": "http://registry.npm.xiaojukeji.com/@babel/helper-plugin-utils/download/@babel/helper-plugin-utils-7.0.0.tgz",
"integrity": "sha1-u7P77phmHFaQNCN8wDlnupm08lA="
},
"@babel/helper-split-export-declaration": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz",
...
...
@@ -648,7 +643,8 @@
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=",
"optional": true
},
"asn1": {
"version": "0.2.4",
...
...
@@ -2213,7 +2209,6 @@
"resolved": "http://registry.npm.xiaojukeji.com/rework/download/rework-1.0.1.tgz",
"integrity": "sha1-MIBqhBNCtUUQqkEQhQzUhTQUSqc=",
"requires": {
"convert-source-map": "0.3.5",
"css": "2.2.4"
}
},
...
...
@@ -2278,7 +2273,6 @@
"requires": {
"@babel/parser": "7.2.3",
"@babel/traverse": "7.2.3",
"bulk-require": "1.0.1",
"chalk": "2.4.2",
"chameleon-tool-utils": "0.3.0-alpha.2",
"cml-component-parser": "0.3.0-alpha.2",
...
...
@@ -2316,10 +2310,8 @@
"resolved": "https://registry.npmjs.org/cml-htmllint/-/cml-htmllint-0.3.0-alpha.2.tgz",
"integrity": "sha512-oD/i71ivAGWppPmKAdsKj/jK1BvepHTAEOTqmdKwSpwLPFpzm2mHQdaBq9omLWflXkFE4JMH01aaeMtMRM7wgQ==",
"requires": {
"bulk-require": "1.0.1",
"htmlparser2": "3.10.0",
"lodash": "4.17.11",
"promise": "8.0.2"
"htmlparser2": "3.10.1",
"lodash": "4.17.11"
}
},
"cml-interface-parser": {
...
...
@@ -2340,7 +2332,6 @@
"requires": {
"@babel/parser": "7.2.3",
"@babel/traverse": "7.2.3",
"bulk-require": "1.0.1",
"chameleon-tool-utils": "0.3.0-alpha.2"
}
},
...
...
@@ -2504,7 +2495,6 @@
"requires": {
"@babel/generator": "7.2.2",
"@babel/parser": "7.4.3",
"@babel/plugin-syntax-jsx": "7.2.0",
"@babel/traverse": "7.2.3",
"@babel/types": "7.2.2",
"babylon": "6.18.0",
...
...
@@ -7336,10 +7326,13 @@
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s="
},
"mvvm-
pack
": {
"mvvm-
cml-loader
": {
"version": "0.0.1",
"resolved": "http://registry.npm.xiaojukeji.com/mvvm-pack/download/mvvm-pack-0.0.1.tgz",
"integrity": "sha1-vz6f751GJYc8pn2cmKrjBa22+vk="
"resolved": "https://registry.npmjs.org/mvvm-cml-loader/-/mvvm-cml-loader-0.0.1.tgz",
"integrity": "sha512-bUzxfNzMq/mcqAOlx03JIzyZNrrtUFrm1XF4zJm51bGrkEk0TfhaZkaCVo+Z/qQjSfSY0yqJD8pQ4OZtbUmJSA==",
"requires": {
"loader-utils": "1.2.3"
}
},
"nan": {
"version": "2.13.2",
...
...
@@ -11462,14 +11455,6 @@
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
"dev": true
},
"promise": {
"version": "8.0.3",
"resolved": "http://registry.npm.xiaojukeji.com/promise/download/promise-8.0.3.tgz",
"integrity": "sha1-9ZLgmcbN3AANU47nKDuxkEUrC/Y=",
"requires": {
"asap": "2.0.6"
}
},
"promise-inflight": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz",
...
...
packages/chameleon-tool/package.json
浏览文件 @
4d8cce14
...
...
@@ -74,6 +74,7 @@
"less"
:
"3.0.4"
,
"less-loader"
:
"4.1.0"
,
"minimist"
:
"1.2.0"
,
"mvvm-cml-loader"
:
"0.0.1"
,
"mvvm-pack"
:
"0.3.0-alpha.2"
,
"node-phpcgi"
:
"0.3.7"
,
"node-watch"
:
"^0.5.9"
,
...
...
packages/chameleon-weex-vue-loader/lib/loader.js
浏览文件 @
4d8cce14
...
...
@@ -450,8 +450,8 @@ module.exports = function (content) {
output
+=
'
module.exports.el =
\'
'
+
params
.
entry
+
'
\'\n
'
+
'
new Vue(module.exports)
\n
'
}
//
console.log(output)
console
.
log
(
output
)
debugger
// done
return
output
}
packages/chameleon-weex-vue-loader/lib/style-loader.js
浏览文件 @
4d8cce14
...
...
@@ -26,6 +26,7 @@ function convertLength (k, v) {
}
function
genStyleString
(
input
,
loader
)
{
debugger
var
output
=
'
{}
'
styler
.
parse
(
input
,
function
(
err
,
obj
)
{
if
(
err
)
{
...
...
packages/interface-loader/src/index.js
浏览文件 @
4d8cce14
...
...
@@ -9,7 +9,6 @@ module.exports = function (source) {
let
{
cmlType
,
media
,
check
=
{}}
=
options
;
const
filePath
=
this
.
resourcePath
;
let
self
=
this
;
debugger
const
resolve
=
function
(
filePath
,
relativePath
)
{
let
context
=
path
.
dirname
(
filePath
);
...
...
packages/mvvm-cml-loader/.eslintrc
0 → 100644
浏览文件 @
4d8cce14
此差异已折叠。
点击以展开。
packages/mvvm-cml-loader/.gitignore
0 → 100644
浏览文件 @
4d8cce14
# Editor directories and files
.DS_Store
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
dist/
# ///////////////////////////
packages/mvvm-cml-loader/helper.js
0 → 100644
浏览文件 @
4d8cce14
const
path
=
require
(
'
path
'
);
exports
.
stringifyLoaders
=
function
(
loaders
)
{
return
loaders
.
map
(
obj
=>
obj
&&
typeof
obj
===
'
object
'
&&
typeof
obj
.
loader
===
'
string
'
?
obj
.
loader
+
(
obj
.
options
?
'
?
'
+
JSON
.
stringify
(
obj
.
options
)
:
''
)
:
obj
)
.
join
(
'
!
'
)
}
exports
.
getSelector
=
function
()
{
return
path
.
resolve
(
__dirname
,
'
./selector.js
'
)
}
exports
.
getPartLoaders
=
function
({
selectorOptions
,
partType
,
lang
,
loaders
,
resourcePath
})
{
selectorOptions
.
partType
=
partType
;
let
resultLoaders
=
[
{
loader
:
exports
.
getSelector
(),
options
:
selectorOptions
}
]
switch
(
partType
)
{
case
'
style
'
:
var
styleLoader
=
loaders
[
lang
];
resultLoaders
=
styleLoader
.
concat
(
resultLoaders
);
break
;
case
'
script
'
:
var
jsLoader
=
loaders
.
js
;
resultLoaders
=
jsLoader
.
concat
(
resultLoaders
);
break
;
default
:
break
;
}
let
stringLoaders
=
exports
.
stringifyLoaders
(
resultLoaders
);
return
'
!
'
+
stringLoaders
+
'
!
'
+
resourcePath
;
}
packages/mvvm-cml-loader/index.js
0 → 100644
浏览文件 @
4d8cce14
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
helper
=
require
(
'
./helper.js
'
);
const
cmlUtils
=
require
(
'
chameleon-tool-utils
'
);
module
.
exports
=
function
(
source
)
{
let
output
=
''
;
const
self
=
this
;
const
rawOptions
=
loaderUtils
.
getOptions
(
this
)
||
{};
let
{
loaders
,
cmlType
,
media
,
check
}
=
rawOptions
;
const
resourcePath
=
this
.
resourcePath
;
// const context = (
// this.rootContext ||
// (this.options && this.options.context) ||
// process.cwd()
// )
let
selectorOptions
=
{
cmlType
,
media
,
check
}
let
parts
=
cmlUtils
.
splitParts
({
content
:
source
});
if
(
parts
.
style
.
length
>
0
)
{
throw
new
Error
(
`
${
resourcePath
}
only allow has one <style></style>`
)
}
if
(
parts
.
style
&&
parts
.
style
[
0
])
{
let
part
=
parts
.
style
[
0
];
let
lang
=
part
.
attrs
&&
part
.
attrs
.
lang
||
'
less
'
;
output
+=
`
var style = require('
${
helper
.
getPartLoaders
({
selectorOptions
,
partType
:
'
style
'
,
lang
,
loaders
,
resourcePath
})}
');
`
}
output
+=
`
var template = require('
${
helper
.
getPartLoaders
({
selectorOptions
,
partType
:
'
template
'
,
loaders
,
resourcePath
})}
');
`
output
+=
`
var json = require('
${
helper
.
getPartLoaders
({
selectorOptions
,
partType
:
'
json
'
,
loaders
,
resourcePath
})}
');
`
output
+=
`
var script = require('
${
helper
.
getPartLoaders
({
selectorOptions
,
partType
:
'
script
'
,
loaders
,
resourcePath
})}
');
`
debugger
return
output
;
}
packages/mvvm-cml-loader/package.json
0 → 100644
浏览文件 @
4d8cce14
{
"name"
:
"mvvm-cml-loader"
,
"version"
:
"0.0.1"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
"Chameleon-Team"
,
"license"
:
"Apache"
,
"dependencies"
:
{
"chameleon-tool-utils"
:
"^0.3.0-alpha.2"
,
"loader-utils"
:
"^1.2.3"
}
}
packages/mvvm-cml-loader/selector.js
0 → 100644
浏览文件 @
4d8cce14
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
cmlUtils
=
require
(
'
chameleon-tool-utils
'
);
module
.
exports
=
function
(
source
)
{
const
rawOptions
=
loaderUtils
.
getOptions
(
this
)
||
{};
let
{
partType
}
=
rawOptions
;
let
parts
=
cmlUtils
.
splitParts
({
content
:
source
});
let
output
=
''
;
switch
(
partType
)
{
case
'
style
'
:
output
=
parts
.
style
[
0
].
content
;
break
;
case
'
script
'
:
parts
.
script
.
forEach
(
item
=>
{
if
(
item
.
cmlType
!==
'
json
'
)
{
output
=
item
.
content
;
}
})
break
;
case
'
template
'
:
output
=
parts
.
template
&&
parts
.
template
[
0
]
&&
parts
.
template
[
0
].
content
;
break
;
case
'
json
'
:
parts
.
script
.
forEach
(
item
=>
{
if
(
item
.
cmlType
===
'
json
'
)
{
output
=
item
.
content
;
}
})
break
;
default
:
break
;
}
return
output
;
}
\ No newline at end of file
packages/mvvm-pack/lib/Compile.js
浏览文件 @
4d8cce14
...
...
@@ -74,6 +74,7 @@ class Compile {
]
this
.
resolve
=
this
.
resolve
.
bind
(
this
);
this
.
outputFileList
=
{};
// 输出对象
}
// path 是源文件路径 request是要解析的路径
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录