提交 9d5d8be4 编写于 作者: S sushuang

tweak build.

上级 e4a010e6
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"debug": false, "debug": false,
"eqnull": true, "eqnull": true,
"esversion": 6, "esversion": 6,
"module": true,
"evil": true, "evil": true,
"expr": true, "expr": true,
"funcscope": false, "funcscope": false,
......
{
"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": false,
"forin": false,
"immed": true,
"latedef": false,
"newcap": true,
"noarg": false,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": false,
"maxparams": 20,
"maxdepth": 6,
"maxlen": 200,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esversion": 6,
"evil": true,
"expr": true,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": false,
"loopfunc": false,
"multistr": false,
"onecase": false,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": true,
"sub": true,
"supernew": false,
"validthis": true,
"browser": true,
"couch": false,
"devel": true,
"dojo": false,
"jquery": true,
"mootools": false,
"node": false,
"nonstandard": false,
"prototypejs": false,
"rhino": false,
"wsh": false,
"nomen": false,
"onevar": false,
"passfail": false,
"white": false,
"varstmt": true,
"predef": [
"__DEV__",
"global",
"require",
"exports",
"Buffer",
"__dirname"
]
}
\ No newline at end of file
#!/usr/bin/env node #!/usr/bin/env node
let fsExtra = require('fs-extra'); const fsExtra = require('fs-extra');
let {resolve} = require('path'); const {resolve} = require('path');
let config = require('./config.js'); const config = require('./config.js');
let commander = require('commander'); const commander = require('commander');
let {build, watch} = require('./helper'); const {build, watch} = require('./helper');
function run() { function run() {
...@@ -60,11 +60,11 @@ function run() { ...@@ -60,11 +60,11 @@ function run() {
let configs = []; let configs = [];
if (isWatch) { if (isWatch) {
watch(config.createEChartsBuild(opt)); watch(config.createECharts(opt));
} }
else { else {
if (!buildAll) { if (!buildAll) {
configs = [config.createEChartsBuild(opt)]; configs = [config.createECharts(opt)];
} }
else { else {
configs = []; configs = [];
...@@ -76,15 +76,15 @@ function run() { ...@@ -76,15 +76,15 @@ function run() {
{min: true, lang: 'en'} {min: true, lang: 'en'}
].forEach(function (opt) { ].forEach(function (opt) {
['', 'simple', 'common'].forEach(function (type) { ['', 'simple', 'common'].forEach(function (type) {
configs.push(config.createEChartsBuild(Object.assign({type}, opt))); configs.push(config.createECharts(Object.assign({type}, opt)));
}); });
}); });
configs.push( configs.push(
config.createBMapBuild(false), config.createBMap(false),
config.createBMapBuild(true), config.createBMap(true),
config.createDataToolBuild(false), config.createDataTool(false),
config.createDataToolBuild(true) config.createDataTool(true)
); );
} }
...@@ -96,7 +96,10 @@ function run() { ...@@ -96,7 +96,10 @@ function run() {
} }
} }
// Based on echarts dir/ /**
* @param {string} relativePath Based on echarts directory.
* @return {string} Absolute path.
*/
function getPath(relativePath) { function getPath(relativePath) {
return resolve(__dirname, '../', relativePath); return resolve(__dirname, '../', relativePath);
} }
......
/* global require, __dirname, exports */ const nodeResolvePlugin = require('rollup-plugin-node-resolve');
const uglifyPlugin = require('rollup-plugin-uglify');
let nodeResolvePlugin = require('rollup-plugin-node-resolve'); const {dirname, resolve} = require('path');
let uglifyPlugin = require('rollup-plugin-uglify');
let {dirname, resolve} = require('path');
// Based on echarts/ // Based on echarts/
function getPath(relativePath) { function getPath(relativePath) {
...@@ -49,7 +47,7 @@ function getPlugins(min, lang) { ...@@ -49,7 +47,7 @@ function getPlugins(min, lang) {
* @param {boolean} [opt.min=false] * @param {boolean} [opt.min=false]
* @param {string} [opt.lang=undefined] null/undefined/'' or 'en' or 'fi' or ... * @param {string} [opt.lang=undefined] null/undefined/'' or 'en' or 'fi' or ...
*/ */
exports.createEChartsBuild = function (opt) { exports.createECharts = function (opt) {
opt = opt || {}; opt = opt || {};
let postfixType = opt.type ? '.' + opt.type : ''; let postfixType = opt.type ? '.' + opt.type : '';
let postfixMin = opt.min ? '.min' : ''; let postfixMin = opt.min ? '.min' : '';
...@@ -74,7 +72,7 @@ exports.createEChartsBuild = function (opt) { ...@@ -74,7 +72,7 @@ exports.createEChartsBuild = function (opt) {
/** /**
* @param {boolean} [min=false] * @param {boolean} [min=false]
*/ */
exports.createBMapBuild = function (min) { exports.createBMap = function (min) {
let postfix = min ? '.min' : ''; let postfix = min ? '.min' : '';
return { return {
...@@ -101,7 +99,7 @@ exports.createBMapBuild = function (min) { ...@@ -101,7 +99,7 @@ exports.createBMapBuild = function (min) {
/** /**
* @param {boolean} [min=false] * @param {boolean} [min=false]
*/ */
exports.createDataToolBuild = function (min) { exports.createDataTool = function (min) {
let postfix = min ? '.min' : ''; let postfix = min ? '.min' : '';
return { return {
plugins: getPlugins(min), plugins: getPlugins(min),
...@@ -123,3 +121,18 @@ exports.createDataToolBuild = function (min) { ...@@ -123,3 +121,18 @@ exports.createDataToolBuild = function (min) {
} }
}; };
}; };
/**
* @param {string} [absolutePath]
*/
exports.createSingleModule = function (absolutePath) {
return {
plugins: getPlugins(),
input: absolutePath,
legacy: true, // Support IE8-
output: {
name: 'echarts',
format: 'amd'
}
};
};
/* global require, exports */ const rollup = require('rollup');
let rollup = require('rollup');
/** /**
* @param {Array.<Object>} configs A list of rollup configs: * @param {Array.<Object>} configs A list of rollup configs:
...@@ -14,45 +12,50 @@ let rollup = require('rollup'); ...@@ -14,45 +12,50 @@ let rollup = require('rollup');
* }, * },
* ... * ...
* ] * ]
* @return {Promise}
*/ */
exports.build = function (configs) { exports.build = function (configs) {
let index = 0; return new Promise(function (promiseResolve, promiseReject) {
let index = 0;
buildSingle(); buildSingle();
function buildSingle() { function buildSingle() {
let singleConfig = configs[index++]; let singleConfig = configs[index++];
if (!singleConfig) { if (!singleConfig) {
return; promiseResolve();
} return;
}
console.log( console.log(
color('fgCyan', 'dim')('\nBundles '), color('fgCyan', 'dim')('\nBundles '),
color('fgCyan')(singleConfig.input), color('fgCyan')(singleConfig.input),
color('fgCyan', 'dim')('=>'), color('fgCyan', 'dim')('=>'),
color('fgCyan')(singleConfig.output.file), color('fgCyan')(singleConfig.output.file),
color('fgCyan', 'dim')(' ...') color('fgCyan', 'dim')(' ...')
); );
rollup rollup
.rollup(singleConfig) .rollup(singleConfig)
.then(function (bundle) { .then(function (bundle) {
return bundle.write(singleConfig.output); return bundle.write(singleConfig.output);
}) })
.then(function () { .then(function () {
console.log( console.log(
color('fgGreen', 'dim')('Created '), color('fgGreen', 'dim')('Created '),
color('fgGreen')(singleConfig.output.file), color('fgGreen')(singleConfig.output.file),
color('fgGreen', 'dim')(' successfully.') color('fgGreen', 'dim')(' successfully.')
); );
buildSingle(); buildSingle();
}) })
.catch(function (err) { .catch(function (err) {
console.log(color('fgRed')(err)); console.log(color('fgRed')(err));
}); promiseReject();
} });
} }
});
};
/** /**
* @param {Object} singleConfig A single rollup config: * @param {Object} singleConfig A single rollup config:
...@@ -65,7 +68,7 @@ exports.build = function (configs) { ...@@ -65,7 +68,7 @@ exports.build = function (configs) {
* } * }
*/ */
exports.watch = function (singleConfig) { exports.watch = function (singleConfig) {
var watcher = rollup.watch(singleConfig); let watcher = rollup.watch(singleConfig);
watcher.on('event', function (event) { watcher.on('event', function (event) {
// event.code can be one of: // event.code can be one of:
...@@ -89,7 +92,7 @@ exports.watch = function (singleConfig) { ...@@ -89,7 +92,7 @@ exports.watch = function (singleConfig) {
printWatchResult(event); printWatchResult(event);
} }
}); });
} };
function printWatchResult(event) { function printWatchResult(event) {
console.log( console.log(
...@@ -155,12 +158,12 @@ const COLOR_MAP = { ...@@ -155,12 +158,12 @@ const COLOR_MAP = {
* Print colored text with `console.log`. * Print colored text with `console.log`.
* *
* Usage: * Usage:
* var color = require('colorConsole'); * let color = require('colorConsole');
* color('fgCyan')('some text'); // cyan text. * color('fgCyan')('some text'); // cyan text.
* color('fgCyan', 'bright')('some text'); // bright cyan text. * color('fgCyan', 'bright')('some text'); // bright cyan text.
* color('fgCyan', 'bgRed')('some text') // cyan text and red background. * color('fgCyan', 'bgRed')('some text') // cyan text and red background.
*/ */
function color() { let color = exports.color = function () {
let prefix = []; let prefix = [];
for (let i = 0; i < arguments.length; i++) { for (let i = 0; i < arguments.length; i++) {
let color = COLOR_MAP[arguments[i]]; let color = COLOR_MAP[arguments[i]];
...@@ -171,4 +174,4 @@ function color() { ...@@ -171,4 +174,4 @@ function color() {
return function (text) { return function (text) {
return prefix + text + COLOR_RESET; return prefix + text + COLOR_RESET;
}; };
} };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册