Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
ec03c9d6
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ec03c9d6
编写于
11月 03, 2017
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enhance build tool.
上级
a5469419
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
28 deletion
+99
-28
build/build.js
build/build.js
+55
-14
build/config.js
build/config.js
+44
-14
未找到文件。
build/build.js
浏览文件 @
ec03c9d6
...
...
@@ -20,7 +20,19 @@ function run() {
commander
.
usage
(
'
[options]
'
)
.
description
(
'
Build echarts and generate result files in directory `echarts/dist`.
'
)
.
description
([
'
Build echarts and generate result files in directory `echarts/dist`.
'
,
''
,
'
For example:
'
,
''
,
'
node build/build.js --release # Build all to `dist` folder.
'
,
'
node build/build.js --type "" # Only generate `dist/echarts.js`.
'
,
'
node build/build.js --type common --min # Only generate `dist/echarts.common.min.js`.
'
,
'
node build/build.js --type simple --min --lang en # Only generate `dist/echarts-en.simple.min.js`.
'
,
'
node build/build.js --min --lang en -i "/my/index.js" -o "/my/ec.js"
'
+
'
# Take `/my/index.js` as input and generate a bundle `/my/ec.js`,
'
+
'
which is in EN language and has been minified.
'
,
].
join
(
'
\n
'
))
.
option
(
'
-w, --watch
'
,
'
Watch modifications of files and auto-compile to dist file (e.g., `echarts/dist/echarts.js`).
'
...
...
@@ -31,6 +43,10 @@ function run() {
+
'
A langXX.js file is required in directory `echarts`.
'
+
'
e.g., `--lang en`, where a file `langEN.js` is required.
'
)
.
option
(
'
--release
'
,
'
Build all for release
'
)
.
option
(
'
--min
'
,
'
Whether to compress the output file.
'
...
...
@@ -40,20 +56,45 @@ function run() {
'
Can be "simple" or "common" or "" (default).
'
+
'
e.g., `--type ""` or `--type "common"`.
'
)
.
option
(
'
--sourcemap
'
,
'
Whether output sourcemap.
'
)
.
option
(
'
--format <format>
'
,
'
The format of output bundle. Can be "umd", "amd", "iife", "cjs", "es".
'
)
.
option
(
'
-i, --input <input file path>
'
,
'
If input file path is specified, output file path must be specified too.
'
)
.
option
(
'
-o, --output <output file path>
'
,
'
If output file path is specified, input file path must be specified too.
'
)
.
parse
(
process
.
argv
);
let
opt
=
{};
let
isWatch
=
!!
commander
.
watch
;
opt
.
lang
=
commander
.
lang
||
null
;
opt
.
min
=
!!
commander
.
min
;
opt
.
type
=
commander
.
type
||
''
;
let
buildAll
=
commander
.
watch
==
null
&&
commander
.
lang
==
null
&&
commander
.
min
==
null
&&
commander
.
type
==
null
;
let
isRelease
=
!!
commander
.
release
;
let
opt
=
{
lang
:
commander
.
lang
||
null
,
min
:
!!
commander
.
min
,
type
:
commander
.
type
||
''
,
input
:
commander
.
input
,
output
:
commander
.
output
,
sourcemap
:
!!
commander
.
sourcemap
,
format
:
commander
.
format
||
'
umd
'
};
if
((
opt
.
input
!=
null
&&
opt
.
output
==
null
)
||
(
opt
.
input
==
null
&&
opt
.
output
!=
null
)
)
{
throw
new
Error
(
'
`input` and `output` must be both set.
'
);
}
// Clear `echarts/dist`
if
(
buildAll
)
{
if
(
isRelease
)
{
fsExtra
.
removeSync
(
getPath
(
'
./dist
'
));
}
...
...
@@ -63,10 +104,7 @@ function run() {
watch
(
config
.
createECharts
(
opt
));
}
else
{
if
(
!
buildAll
)
{
configs
=
[
config
.
createECharts
(
opt
)];
}
else
{
if
(
isRelease
)
{
configs
=
[];
[
...
...
@@ -87,6 +125,9 @@ function run() {
config
.
createDataTool
(
true
)
);
}
else
{
configs
=
[
config
.
createECharts
(
opt
)];
}
build
(
configs
);
...
...
build/config.js
浏览文件 @
ec03c9d6
/* global process */
const
nodeResolvePlugin
=
require
(
'
rollup-plugin-node-resolve
'
);
const
uglifyPlugin
=
require
(
'
rollup-plugin-uglify
'
);
const
{
dirname
,
resolve
}
=
require
(
'
path
'
);
// Based on echarts/
function
getPath
(
relativePath
)
{
return
resolve
(
__dirname
,
'
../
'
,
relativePath
);
function
getPathBasedOnECharts
(
path
)
{
return
resolve
(
__dirname
,
'
../
'
,
path
);
}
/**
...
...
@@ -46,26 +46,56 @@ function getPlugins(min, lang) {
* @param {string} [opt.type=''] '' or 'simple' or 'common'
* @param {boolean} [opt.min=false]
* @param {string} [opt.lang=undefined] null/undefined/'' or 'en' or 'fi' or ...
* @param {string} [opt.input=undefined] If set, `opt.output` is required too, and `opt.type` is ignored.
* @param {string} [opt.output=undefined] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.sourcemap] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {string} [opt.format='umd'] If set, `opt.input` is required too, and `opt.type` is ignored.
*/
exports
.
createECharts
=
function
(
opt
)
{
opt
=
opt
||
{};
let
postfixType
=
opt
.
type
?
'
.
'
+
opt
.
type
:
''
;
let
postfixMin
=
opt
.
min
?
'
.min
'
:
''
;
let
postfixLang
=
opt
.
lang
?
'
-
'
+
opt
.
lang
.
toLowerCase
()
:
''
;
let
isCustom
;
let
input
=
opt
.
input
;
let
output
=
opt
.
output
;
let
sourcemap
=
opt
.
sourcemap
;
let
format
=
opt
.
format
||
'
umd
'
;
if
(
input
!=
null
||
output
!=
null
)
{
if
(
input
==
null
||
output
==
null
)
{
throw
new
Error
(
'
`input` and `output` must be both set.
'
);
}
isCustom
=
true
;
// Based on process.cwd();
input
=
resolve
(
input
);
output
=
resolve
(
output
);
}
else
{
input
=
getPathBasedOnECharts
(
`./index
${
postfixType
}
.js`
);
output
=
getPathBasedOnECharts
(
`dist/echarts
${
postfixLang
}${
postfixType
}${
postfixMin
}
.js`
);
if
(
sourcemap
==
null
)
{
sourcemap
=
!
opt
.
min
&&
!
postfixType
;
}
}
return
{
plugins
:
getPlugins
(
opt
.
min
,
opt
.
lang
),
input
:
getPath
(
`./index
${
postfixType
}
.js`
)
,
input
:
input
,
legacy
:
true
,
// Support IE8-
output
:
{
name
:
'
echarts
'
,
format
:
'
umd
'
,
sourcemap
:
!
opt
.
min
&&
!
postfixType
,
format
:
format
,
sourcemap
:
sourcemap
,
legacy
:
true
,
// Must be declared both in inputOptions and outputOptions.
file
:
getPath
(
`dist/echarts
${
postfixLang
}${
postfixType
}${
postfixMin
}
.js`
)
file
:
output
},
watch
:
{
include
:
[
getPath
(
'
./src/**
'
),
getPath
(
'
./index*.js
'
),
getPath
(
'
../zrender/src/**
'
)]
include
:
[
getPathBasedOnECharts
(
'
./src/**
'
),
getPathBasedOnECharts
(
'
./index*.js
'
),
getPathBasedOnECharts
(
'
../zrender/src/**
'
)
]
}
};
};
...
...
@@ -78,7 +108,7 @@ exports.createBMap = function (min) {
return
{
plugins
:
getPlugins
(
min
),
input
:
getPath
(
`./extension/bmap/bmap.js`
),
input
:
getPath
BasedOnECharts
(
`./extension/bmap/bmap.js`
),
legacy
:
true
,
// Support IE8-
external
:
[
'
echarts
'
],
output
:
{
...
...
@@ -90,10 +120,10 @@ exports.createBMap = function (min) {
// For UMD `global.echarts`
echarts
:
'
echarts
'
},
file
:
getPath
(
`dist/extension/bmap
${
postfix
}
.js`
)
file
:
getPath
BasedOnECharts
(
`dist/extension/bmap
${
postfix
}
.js`
)
},
watch
:
{
include
:
[
getPath
(
'
./extension/bmap/**
'
)]
include
:
[
getPath
BasedOnECharts
(
'
./extension/bmap/**
'
)]
}
};
};
...
...
@@ -105,7 +135,7 @@ exports.createDataTool = function (min) {
let
postfix
=
min
?
'
.min
'
:
''
;
return
{
plugins
:
getPlugins
(
min
),
input
:
getPath
(
`./extension/dataTool/index.js`
),
input
:
getPath
BasedOnECharts
(
`./extension/dataTool/index.js`
),
legacy
:
true
,
// Support IE8-
external
:
[
'
echarts
'
],
output
:
{
...
...
@@ -117,10 +147,10 @@ exports.createDataTool = function (min) {
// For UMD `global.echarts`
echarts
:
'
echarts
'
},
file
:
getPath
(
`dist/extension/dataTool
${
postfix
}
.js`
)
file
:
getPath
BasedOnECharts
(
`dist/extension/dataTool
${
postfix
}
.js`
)
},
watch
:
{
include
:
[
getPath
(
'
./extension/dataTool/**
'
)]
include
:
[
getPath
BasedOnECharts
(
'
./extension/dataTool/**
'
)]
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录