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

tweak build.

上级 e4a010e6
......@@ -26,6 +26,7 @@
"debug": false,
"eqnull": true,
"esversion": 6,
"module": true,
"evil": true,
"expr": true,
"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
let fsExtra = require('fs-extra');
let {resolve} = require('path');
let config = require('./config.js');
let commander = require('commander');
let {build, watch} = require('./helper');
const fsExtra = require('fs-extra');
const {resolve} = require('path');
const config = require('./config.js');
const commander = require('commander');
const {build, watch} = require('./helper');
function run() {
......@@ -60,11 +60,11 @@ function run() {
let configs = [];
if (isWatch) {
watch(config.createEChartsBuild(opt));
watch(config.createECharts(opt));
}
else {
if (!buildAll) {
configs = [config.createEChartsBuild(opt)];
configs = [config.createECharts(opt)];
}
else {
configs = [];
......@@ -76,15 +76,15 @@ function run() {
{min: true, lang: 'en'}
].forEach(function (opt) {
['', 'simple', 'common'].forEach(function (type) {
configs.push(config.createEChartsBuild(Object.assign({type}, opt)));
configs.push(config.createECharts(Object.assign({type}, opt)));
});
});
configs.push(
config.createBMapBuild(false),
config.createBMapBuild(true),
config.createDataToolBuild(false),
config.createDataToolBuild(true)
config.createBMap(false),
config.createBMap(true),
config.createDataTool(false),
config.createDataTool(true)
);
}
......@@ -96,7 +96,10 @@ function run() {
}
}
// Based on echarts dir/
/**
* @param {string} relativePath Based on echarts directory.
* @return {string} Absolute path.
*/
function getPath(relativePath) {
return resolve(__dirname, '../', relativePath);
}
......
/* global require, __dirname, exports */
let nodeResolvePlugin = require('rollup-plugin-node-resolve');
let uglifyPlugin = require('rollup-plugin-uglify');
let {dirname, resolve} = require('path');
const nodeResolvePlugin = require('rollup-plugin-node-resolve');
const uglifyPlugin = require('rollup-plugin-uglify');
const {dirname, resolve} = require('path');
// Based on echarts/
function getPath(relativePath) {
......@@ -49,7 +47,7 @@ function getPlugins(min, lang) {
* @param {boolean} [opt.min=false]
* @param {string} [opt.lang=undefined] null/undefined/'' or 'en' or 'fi' or ...
*/
exports.createEChartsBuild = function (opt) {
exports.createECharts = function (opt) {
opt = opt || {};
let postfixType = opt.type ? '.' + opt.type : '';
let postfixMin = opt.min ? '.min' : '';
......@@ -74,7 +72,7 @@ exports.createEChartsBuild = function (opt) {
/**
* @param {boolean} [min=false]
*/
exports.createBMapBuild = function (min) {
exports.createBMap = function (min) {
let postfix = min ? '.min' : '';
return {
......@@ -101,7 +99,7 @@ exports.createBMapBuild = function (min) {
/**
* @param {boolean} [min=false]
*/
exports.createDataToolBuild = function (min) {
exports.createDataTool = function (min) {
let postfix = min ? '.min' : '';
return {
plugins: getPlugins(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 */
let rollup = require('rollup');
const rollup = require('rollup');
/**
* @param {Array.<Object>} configs A list of rollup configs:
......@@ -14,45 +12,50 @@ let rollup = require('rollup');
* },
* ...
* ]
* @return {Promise}
*/
exports.build = function (configs) {
let index = 0;
return new Promise(function (promiseResolve, promiseReject) {
let index = 0;
buildSingle();
buildSingle();
function buildSingle() {
let singleConfig = configs[index++];
function buildSingle() {
let singleConfig = configs[index++];
if (!singleConfig) {
return;
}
if (!singleConfig) {
promiseResolve();
return;
}
console.log(
color('fgCyan', 'dim')('\nBundles '),
color('fgCyan')(singleConfig.input),
color('fgCyan', 'dim')('=>'),
color('fgCyan')(singleConfig.output.file),
color('fgCyan', 'dim')(' ...')
);
console.log(
color('fgCyan', 'dim')('\nBundles '),
color('fgCyan')(singleConfig.input),
color('fgCyan', 'dim')('=>'),
color('fgCyan')(singleConfig.output.file),
color('fgCyan', 'dim')(' ...')
);
rollup
.rollup(singleConfig)
.then(function (bundle) {
return bundle.write(singleConfig.output);
})
.then(function () {
console.log(
color('fgGreen', 'dim')('Created '),
color('fgGreen')(singleConfig.output.file),
color('fgGreen', 'dim')(' successfully.')
);
buildSingle();
})
.catch(function (err) {
console.log(color('fgRed')(err));
});
}
}
rollup
.rollup(singleConfig)
.then(function (bundle) {
return bundle.write(singleConfig.output);
})
.then(function () {
console.log(
color('fgGreen', 'dim')('Created '),
color('fgGreen')(singleConfig.output.file),
color('fgGreen', 'dim')(' successfully.')
);
buildSingle();
})
.catch(function (err) {
console.log(color('fgRed')(err));
promiseReject();
});
}
});
};
/**
* @param {Object} singleConfig A single rollup config:
......@@ -65,7 +68,7 @@ exports.build = function (configs) {
* }
*/
exports.watch = function (singleConfig) {
var watcher = rollup.watch(singleConfig);
let watcher = rollup.watch(singleConfig);
watcher.on('event', function (event) {
// event.code can be one of:
......@@ -89,7 +92,7 @@ exports.watch = function (singleConfig) {
printWatchResult(event);
}
});
}
};
function printWatchResult(event) {
console.log(
......@@ -155,12 +158,12 @@ const COLOR_MAP = {
* Print colored text with `console.log`.
*
* Usage:
* var color = require('colorConsole');
* let color = require('colorConsole');
* color('fgCyan')('some text'); // cyan text.
* color('fgCyan', 'bright')('some text'); // bright cyan text.
* color('fgCyan', 'bgRed')('some text') // cyan text and red background.
*/
function color() {
let color = exports.color = function () {
let prefix = [];
for (let i = 0; i < arguments.length; i++) {
let color = COLOR_MAP[arguments[i]];
......@@ -171,4 +174,4 @@ function color() {
return function (text) {
return prefix + text + COLOR_RESET;
};
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册