iapyang
5 years ago
36 changed files with 588 additions and 779 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,43 +1,70 @@
|
||||
const Concat = require("concat-with-sourcemaps"); |
||||
const { resolve } = require("path"); |
||||
const fs = require("fs"); |
||||
const { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } = require("fs"); |
||||
const rimraf = require("rimraf"); |
||||
|
||||
function unionJs(filenames) { |
||||
const filename = filenames[0]; |
||||
const dest = resolve(__dirname, '../../dist'); |
||||
|
||||
const concat = new Concat(true, filename, "\n"); |
||||
const $dest = resolve(dest, './2.0'); |
||||
|
||||
filenames.forEach(filename => { |
||||
concat.add( |
||||
filename, |
||||
fs.readFileSync(resolve(__dirname, `../../dist/${filename}`)), |
||||
fs.readFileSync(resolve(__dirname, `../../dist/${filename}.map`)).toString() |
||||
); |
||||
}); |
||||
if (!existsSync($dest)) { |
||||
mkdirSync($dest); |
||||
} |
||||
|
||||
const deleteList = [ |
||||
"bundle.ie.css", |
||||
"bundle_without_normalize.js", |
||||
"bundle_without_normalize.js.map", |
||||
"fineui.ie.css", |
||||
"fineui_without_jquery_polyfill.css", |
||||
]; |
||||
|
||||
const copyList = [{ |
||||
source: "bundle.min", |
||||
exts: ["css", "js", "js.map"], |
||||
targets: ["2.0/fineui", "2.0/fineui.min"], |
||||
}, { |
||||
source: "bundle_without_normalize", |
||||
exts: ["css"], |
||||
targets: ["2.0/fineui_without_normalize", "2.0/fineui_without_normalize.min"], |
||||
}, { |
||||
source: "fineui", |
||||
exts: ["css", "js", "js.map"], |
||||
targets: ["fineui.min"], |
||||
}, { |
||||
source: "utils", |
||||
exts: ["js", "js.map"], |
||||
targets: ["utils.min"], |
||||
}, { |
||||
source: "bundle.ie", |
||||
exts: ["js", "js.map"], |
||||
targets: ["2.0/fineui.ie", "2.0/fineui.ie.min"], |
||||
}]; |
||||
|
||||
copyList.forEach(conf => { |
||||
conf.exts.forEach(ext => { |
||||
const sourcefile = resolve(dest, `./${conf.source}.${ext}`); |
||||
|
||||
// 剔除所有的sourcemap痕迹
|
||||
const concatenatedContent = concat.content.toString().replace(/\/\/# sourceMappingURL=.+/g, ""); |
||||
const sourceMapForContent = concat.sourceMap; |
||||
if (!existsSync(sourcefile)) { |
||||
console.log(`${sourcefile} does not exist!`); |
||||
} |
||||
|
||||
fs.writeFileSync(resolve(__dirname, "../../dist", filename), concatenatedContent, { |
||||
encoding: "utf8", |
||||
conf.targets.forEach(target => { |
||||
copyFileSync(sourcefile, resolve(dest, `./${target}.${ext}`)); |
||||
}); |
||||
}); |
||||
}); |
||||
|
||||
deleteList.forEach(filename => { |
||||
const sourcefile = resolve(dest, `./${filename}`); |
||||
|
||||
fs.writeFileSync(resolve(__dirname, "../../dist", `${filename}.map`), sourceMapForContent, { |
||||
encoding: "utf8", |
||||
rimraf(sourcefile, () => { |
||||
console.log(`${sourcefile} deleted`); |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
const demoJs = resolve(dest, './demo.js'); |
||||
|
||||
const content = `${readFileSync(demoJs, { encoding: 'utf8' })}
|
||||
//# sourceMappingURL=./demo.js.map`;
|
||||
|
||||
unionJs(["bundle.min.js", "es5.fineui.js"]); |
||||
unionJs(["bundle.ie.min.js", "ie.fineui.js"]); |
||||
unionJs(["fineui.min.js", "es5.fineui.js"]); |
||||
unionJs(["fineui.ie.min.js", "ie.fineui.js"]); |
||||
unionJs(["2.0/fineui.min.js", "es5.fineui.js"]); |
||||
unionJs(["2.0/fineui.ie.min.js", "ie.fineui.js"]); |
||||
|
||||
unionJs(["bundle.js", "es5.fineui.js"]); |
||||
unionJs(["2.0/fineui.js", "es5.fineui.js"]); |
||||
unionJs(["bundle.ie.js", "ie.fineui.js"]); |
||||
unionJs(["2.0/fineui.ie.js", "ie.fineui.js"]); |
||||
unionJs(["fineui.js", "es5.fineui.js"]); |
||||
unionJs(["fineui.ie.js", "ie.fineui.js"]); |
||||
writeFileSync(demoJs, content); |
||||
|
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title>Demo</title> |
||||
</head> |
||||
|
||||
<body> |
||||
<div id="wrapper"></div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,243 @@
|
||||
const grunt = require("grunt"); |
||||
|
||||
function uniq(names) { |
||||
return [...new Set(names)]; |
||||
} |
||||
|
||||
function sync(patterns) { |
||||
return uniq(grunt.file.expand({ filter: path => !new RegExp(/__test__/g).test(path) }, patterns)).map(name => `./${name}`); |
||||
} |
||||
|
||||
const basicAttachmentMap = { |
||||
polyfill: sync(["src/core/foundation.js", "src/polyfill/**/*.js"]).concat(["@babel/polyfill", "es6-promise/auto"]), |
||||
polyfillIE: sync(["src/core/foundation.js", "src/polyfill/**/*.js"]).concat([ |
||||
"core-js/features/object/define-property", |
||||
"core-js/features/object/create", |
||||
"core-js/features/object/assign", |
||||
"core-js/features/object/get-own-property-symbols", |
||||
"core-js/features/object/get-prototype-of", |
||||
"core-js/features/array/for-each", |
||||
"core-js/features/array/index-of", |
||||
"core-js/features/function/bind", |
||||
"core-js/features/promise", |
||||
"core-js/features/string/replace", |
||||
"core-js/es/map", |
||||
// "core-js",
|
||||
]), |
||||
core: sync([ |
||||
"src/less/core/**/*.less", |
||||
"src/less/theme/**/*.less", |
||||
"src/core/foundation.js", |
||||
"src/core/lodash.js", |
||||
// 'src/core/mvc/**/*.js',
|
||||
"src/core/base.js", |
||||
"src/core/ob.js", |
||||
"src/core/widget.js", |
||||
// 'src/core/model.js',
|
||||
// 'src/core/view.js',
|
||||
"src/core/shortcut.js", |
||||
"src/core/utils/**/*.js", |
||||
"src/core/behavior/behavior.js", |
||||
"src/core/wrapper/layout.js", |
||||
"src/core/plugin.js", |
||||
"src/core/**/*.js", |
||||
"src/data/data.js", |
||||
"src/data/**/*.js", |
||||
]), |
||||
// 最基础的控件
|
||||
base: sync([ |
||||
"src/less/base/**/*.less", |
||||
"src/third/**/*.js", |
||||
"src/base/pane.js", |
||||
"src/base/single/single.js", |
||||
"src/base/single/text.js", |
||||
"src/base/single/button/button.basic.js", |
||||
"src/base/single/button/button.node.js", |
||||
"src/base/single/tip/tip.js", |
||||
"src/base/combination/group.button.js", |
||||
"src/base/combination/tree.button.js", |
||||
"src/base/tree/ztree/treeview.js", |
||||
"src/base/tree/ztree/asynctree.js", |
||||
"src/base/tree/ztree/parttree.js", |
||||
"src/base/tree/ztree/list/listtreeview.js", |
||||
"src/base/tree/ztree/list/listasynctree.js", |
||||
"src/base/tree/ztree/list/listparttree.js", |
||||
"src/base/**/*.js", |
||||
]), |
||||
// 实现好的一些基础实例
|
||||
case: sync([ |
||||
"src/case/combo/popup.bubble.js", |
||||
"src/case/**/*.js", |
||||
]), |
||||
widget: sync([ |
||||
"src/less/widget/**/*.less", |
||||
"src/widget/**/*.js", |
||||
"src/component/**/*.js", |
||||
]), |
||||
router: sync([ |
||||
"src/router/**/*.js", |
||||
]), |
||||
'core_without_normalize': sync( |
||||
["src/less/core/**/*.less", "src/less/theme/**/*.less", "!src/less/core/normalize.less", "!src/less/core/normalize2.less"], |
||||
), |
||||
resource: sync(["src/less/resource/**/*.less"]), |
||||
font: sync(["public/less/font.less"]), |
||||
ts: ['./typescript/bundle.ts'], |
||||
ui: sync(['ui/js/**/*.js']), |
||||
config: sync(["demo/version.js", "i18n/i18n.cn.js"]), |
||||
utils: sync([ |
||||
"src/core/foundation.js", |
||||
"src/core/lodash.js", |
||||
"src/core/var.js", |
||||
"src/core/func/array.js", |
||||
"src/core/func/number.js", |
||||
"src/core/func/string.js", |
||||
"src/core/func/date.js", |
||||
"src/core/func/function.js", |
||||
"src/core/base.js", |
||||
"src/core/ob.js", |
||||
"src/core/alias.js", |
||||
"src/core/inject.js", |
||||
"src/core/i18n.js", |
||||
"src/core/utils/*.js", |
||||
"i18n/i18n.cn.js", |
||||
"_mobile/date.i18n.cn.js", |
||||
"src/data/data.js", |
||||
"src/data/**/*.js", |
||||
]), |
||||
fix: ['./typescript/fix/fix.ts'], |
||||
fixIE: ['./typescript/fix/fix.ie.ts'], |
||||
}; |
||||
|
||||
const bundle = [].concat( |
||||
basicAttachmentMap.polyfill, |
||||
basicAttachmentMap.core, |
||||
basicAttachmentMap.fix, |
||||
basicAttachmentMap.base, |
||||
basicAttachmentMap.case, |
||||
basicAttachmentMap.widget, |
||||
sync(["public/less/app.less", "public/less/**/*.less"]), |
||||
['./dist/fix/fix.compact.js'], |
||||
basicAttachmentMap.router, |
||||
sync(["public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js"]), |
||||
basicAttachmentMap.ts, |
||||
); |
||||
|
||||
const bundleIE = [].concat( |
||||
basicAttachmentMap.polyfillIE, |
||||
basicAttachmentMap.core, |
||||
basicAttachmentMap.fixIE, |
||||
basicAttachmentMap.base, |
||||
basicAttachmentMap.case, |
||||
basicAttachmentMap.widget, |
||||
sync(["public/less/app.less", "public/less/**/*.less"]), |
||||
['./dist/fix/fix.compact.ie.js'], |
||||
basicAttachmentMap.router, |
||||
sync(["public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js"]), |
||||
basicAttachmentMap.ts, |
||||
); |
||||
|
||||
const bundleWithoutNormalize = [].concat( |
||||
basicAttachmentMap.core_without_normalize, |
||||
sync([ |
||||
"src/less/base/**/*.less", |
||||
"src/less/widget/**/*.less", |
||||
"public/less/app.less", |
||||
"public/less/**/*.less", |
||||
// ts的less
|
||||
]), |
||||
); |
||||
|
||||
const fineui = [].concat( |
||||
basicAttachmentMap.polyfill, |
||||
basicAttachmentMap.core, |
||||
basicAttachmentMap.fix, |
||||
basicAttachmentMap.base, |
||||
basicAttachmentMap.case, |
||||
basicAttachmentMap.widget, |
||||
basicAttachmentMap.router, |
||||
["./dist/fix/fix.compact.js"], |
||||
basicAttachmentMap.ui, |
||||
basicAttachmentMap.ts, |
||||
); |
||||
|
||||
const fineuiIE = [].concat( |
||||
basicAttachmentMap.polyfillIE, |
||||
basicAttachmentMap.core, |
||||
basicAttachmentMap.fixIE, |
||||
basicAttachmentMap.base, |
||||
basicAttachmentMap.case, |
||||
basicAttachmentMap.widget, |
||||
basicAttachmentMap.router, |
||||
["./dist/fix/fix.compact.ie.js"], |
||||
basicAttachmentMap.ui, |
||||
basicAttachmentMap.ts, |
||||
); |
||||
|
||||
const fineuiWithoutJqueryAndPolyfillJs = [].concat( |
||||
sync([ |
||||
"src/core/foundation.js", |
||||
"src/core/lodash.js", |
||||
// 'src/core/mvc/**/*.js',
|
||||
"src/core/base.js", |
||||
"src/core/ob.js", |
||||
"src/core/widget.js", |
||||
// 'src/core/model.js',
|
||||
// 'src/core/view.js',
|
||||
"src/core/shortcut.js", |
||||
"src/core/utils/*.js", |
||||
"src/core/behavior/behavior.js", |
||||
"src/core/wrapper/layout.js", |
||||
"src/core/plugin.js", |
||||
"src/core/**/*.js", |
||||
"!src/core/platform/web/**/*.js", |
||||
"src/data/data.js", |
||||
"src/data/**/*.js", |
||||
"dist/fix/fix.js", |
||||
"src/base/pane.js", |
||||
"src/base/single/single.js", |
||||
"src/base/single/text.js", |
||||
"src/base/single/button/button.basic.js", |
||||
"src/base/single/button/button.node.js", |
||||
"src/base/single/tip/tip.js", |
||||
"src/base/combination/group.button.js", |
||||
"src/base/combination/tree.button.js", |
||||
"src/base/combination/map.button.js", |
||||
"src/base/**/*.js", |
||||
"!src/base/tree/ztree/**/*.js", |
||||
"!src/base/single/input/file.js", |
||||
"src/case/combo/popup.bubble.js", |
||||
"src/case/**/*.js", |
||||
"!src/case/colorchooser/**/*.js", |
||||
"!src/case/tree/ztree/**/*.js", |
||||
]), |
||||
basicAttachmentMap.widget, |
||||
sync(["dist/fix/fix.compact.js", "ui/js/**/*.js"]), |
||||
basicAttachmentMap.ts, |
||||
); |
||||
|
||||
const demo = [].concat( |
||||
basicAttachmentMap.polyfill, |
||||
basicAttachmentMap.core, |
||||
basicAttachmentMap.router, |
||||
basicAttachmentMap.fix, |
||||
basicAttachmentMap.base, |
||||
basicAttachmentMap.case, |
||||
basicAttachmentMap.widget, |
||||
sync(["public/less/app.less", "public/less/**/*.less"]), |
||||
['./dist/fix/fix.compact.js'], |
||||
basicAttachmentMap.config, |
||||
basicAttachmentMap.ts, |
||||
sync(["demo/less/*.less", "demo/less/**/*.less", "demo/app.js", "demo/js/**/*.js", "demo/config.js"]), |
||||
); |
||||
|
||||
module.exports = { |
||||
bundle: uniq(bundle), |
||||
bundleIE: uniq(bundleIE), |
||||
bundleWithoutNormalize: uniq(bundleWithoutNormalize), |
||||
fineui: uniq(fineui), |
||||
fineuiIE: uniq(fineuiIE), |
||||
fineuiWithoutJqueryAndPolyfillJs: uniq(fineuiWithoutJqueryAndPolyfillJs), |
||||
utils: uniq(basicAttachmentMap.utils), |
||||
demo: uniq(demo), |
||||
}; |
Loading…
Reference in new issue