Browse Source

优化build脚本

zxlie 7 years ago
parent
commit
cbf56bcd86

+ 1 - 1
chrome/apps/manifest.json

@@ -1,6 +1,6 @@
 {
     "name": "WEB前端助手(FeHelper)",
-    "version": "2018.04.1101",
+    "version": "2018.04.1201",
     "manifest_version": 2,
     "default_locale": "zh_CN",
 

+ 1 - 67
chrome/apps/static/vendor/codemirror/active-line.js

@@ -1,67 +1 @@
-// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: http://codemirror.net/LICENSE
-
-(function(mod) {
-        mod(CodeMirror);
-})(function(CodeMirror) {
-    "use strict";
-    var WRAP_CLASS = "CodeMirror-activeline";
-    var BACK_CLASS = "CodeMirror-activeline-background";
-    var GUTT_CLASS = "CodeMirror-activeline-gutter";
-
-    CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
-        var prev = old == CodeMirror.Init ? false : old;
-        if (val == prev) return
-        if (prev) {
-            cm.off("beforeSelectionChange", selectionChange);
-            clearActiveLines(cm);
-            delete cm.state.activeLines;
-        }
-        if (val) {
-            cm.state.activeLines = [];
-            updateActiveLines(cm, cm.listSelections());
-            cm.on("beforeSelectionChange", selectionChange);
-        }
-    });
-
-    function clearActiveLines(cm) {
-        for (var i = 0; i < cm.state.activeLines.length; i++) {
-            cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
-            cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
-            cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
-        }
-    }
-
-    function sameArray(a, b) {
-        if (a.length != b.length) return false;
-        for (var i = 0; i < a.length; i++)
-            if (a[i] != b[i]) return false;
-        return true;
-    }
-
-    function updateActiveLines(cm, ranges) {
-        var active = [];
-        for (var i = 0; i < ranges.length; i++) {
-            var range = ranges[i];
-            var option = cm.getOption("styleActiveLine");
-            if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
-                continue
-            var line = cm.getLineHandleVisualStart(range.head.line);
-            if (active[active.length - 1] != line) active.push(line);
-        }
-        if (sameArray(cm.state.activeLines, active)) return;
-        cm.operation(function() {
-            clearActiveLines(cm);
-            for (var i = 0; i < active.length; i++) {
-                cm.addLineClass(active[i], "wrap", WRAP_CLASS);
-                cm.addLineClass(active[i], "background", BACK_CLASS);
-                cm.addLineClass(active[i], "gutter", GUTT_CLASS);
-            }
-            cm.state.activeLines = active;
-        });
-    }
-
-    function selectionChange(cm, sel) {
-        updateActiveLines(cm, sel.ranges);
-    }
-});
+(function(a){a(CodeMirror)})(function(a){"use strict";function b(a){for(var b=0;b<a.state.activeLines.length;b++)a.removeLineClass(a.state.activeLines[b],"wrap","CodeMirror-activeline"),a.removeLineClass(a.state.activeLines[b],"background","CodeMirror-activeline-background"),a.removeLineClass(a.state.activeLines[b],"gutter","CodeMirror-activeline-gutter")}function c(c,a){if(c.length!=a.length)return!1;for(var b=0;b<c.length;b++)if(c[b]!=a[b])return!1;return!0}function d(a,d){for(var e=[],f=0;f<d.length;f++){var g=d[f],h=a.getOption("styleActiveLine");if("object"==typeof h&&h.nonEmpty?g.anchor.line==g.head.line:!!g.empty()){var i=a.getLineHandleVisualStart(g.head.line);e[e.length-1]!=i&&e.push(i)}}c(a.state.activeLines,e)||a.operation(function(){b(a);for(var c=0;c<e.length;c++)a.addLineClass(e[c],"wrap","CodeMirror-activeline"),a.addLineClass(e[c],"background","CodeMirror-activeline-background"),a.addLineClass(e[c],"gutter","CodeMirror-activeline-gutter");a.state.activeLines=e})}function e(a,b){d(a,b.ranges)}a.defineOption("styleActiveLine",!1,function(c,f,g){var h=g!=a.Init&&g;f==h||(h&&(c.off("beforeSelectionChange",e),b(c),delete c.state.activeLines),f&&(c.state.activeLines=[],d(c,c.listSelections()),c.on("beforeSelectionChange",e)))})});

File diff suppressed because it is too large
+ 0 - 9665
chrome/apps/static/vendor/codemirror/codemirror.js


File diff suppressed because it is too large
+ 0 - 862
chrome/apps/static/vendor/codemirror/javascript.js


File diff suppressed because it is too large
+ 0 - 140
chrome/apps/static/vendor/codemirror/matchbrackets.js


+ 1 - 58
chrome/apps/static/vendor/codemirror/placeholder.js

@@ -1,58 +1 @@
-// CodeMirror, copyright (c) by Marijn Haverbeke and others
-// Distributed under an MIT license: http://codemirror.net/LICENSE
-
-(function(mod) {
-        mod(CodeMirror);
-})(function(CodeMirror) {
-    CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
-        var prev = old && old != CodeMirror.Init;
-        if (val && !prev) {
-            cm.on("blur", onBlur);
-            cm.on("change", onChange);
-            cm.on("swapDoc", onChange);
-            onChange(cm);
-        } else if (!val && prev) {
-            cm.off("blur", onBlur);
-            cm.off("change", onChange);
-            cm.off("swapDoc", onChange);
-            clearPlaceholder(cm);
-            var wrapper = cm.getWrapperElement();
-            wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
-        }
-
-        if (val && !cm.hasFocus()) onBlur(cm);
-    });
-
-    function clearPlaceholder(cm) {
-        if (cm.state.placeholder) {
-            cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
-            cm.state.placeholder = null;
-        }
-    }
-    function setPlaceholder(cm) {
-        clearPlaceholder(cm);
-        var elt = cm.state.placeholder = document.createElement("pre");
-        elt.style.cssText = "height: 0; overflow: visible";
-        elt.style.direction = cm.getOption("direction");
-        elt.className = "CodeMirror-placeholder";
-        var placeHolder = cm.getOption("placeholder")
-        if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
-        elt.appendChild(placeHolder)
-        cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
-    }
-
-    function onBlur(cm) {
-        if (isEmpty(cm)) setPlaceholder(cm);
-    }
-    function onChange(cm) {
-        var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
-        wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
-
-        if (empty) setPlaceholder(cm);
-        else clearPlaceholder(cm);
-    }
-
-    function isEmpty(cm) {
-        return (cm.lineCount() === 1) && (cm.getLine(0) === "");
-    }
-});
+(function(a){a(CodeMirror)})(function(a){function b(a){a.state.placeholder&&(a.state.placeholder.parentNode.removeChild(a.state.placeholder),a.state.placeholder=null)}function c(a){b(a);var c=a.state.placeholder=document.createElement("pre");c.style.cssText="height: 0; overflow: visible",c.style.direction=a.getOption("direction"),c.className="CodeMirror-placeholder";var d=a.getOption("placeholder");"string"==typeof d&&(d=document.createTextNode(d)),c.appendChild(d),a.display.lineSpace.insertBefore(c,a.display.lineSpace.firstChild)}function d(a){f(a)&&c(a)}function e(a){var d=a.getWrapperElement(),e=f(a);d.className=d.className.replace(" CodeMirror-empty","")+(e?" CodeMirror-empty":""),e?c(a):b(a)}function f(a){return 1===a.lineCount()&&""===a.getLine(0)}a.defineOption("placeholder","",function(c,f,g){var h=g&&g!=a.Init;if(f&&!h)c.on("blur",d),c.on("change",e),c.on("swapDoc",e),e(c);else if(!f&&h){c.off("blur",d),c.off("change",e),c.off("swapDoc",e),b(c);var i=c.getWrapperElement();i.className=i.className.replace(" CodeMirror-empty","")}f&&!c.hasFocus()&&d(c)})});

File diff suppressed because it is too large
+ 0 - 88
chrome/apps/static/vendor/syntaxhighlighter/shBrushCss.js


+ 1 - 50
chrome/apps/static/vendor/syntaxhighlighter/shBrushJScript.js

@@ -1,50 +1 @@
-/**
- * SyntaxHighlighter
- * http://alexgorbatchev.com/SyntaxHighlighter
- *
- * SyntaxHighlighter is donationware. If you are using it, please donate.
- * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
- *
- * @version
- * 3.0.83 (July 02 2010)
- * 
- * @copyright
- * Copyright (C) 2004-2010 Alex Gorbatchev.
- *
- * @license
- * Dual licensed under the MIT and GPL licenses.
- */
-;(function()
-{
-
-	function Brush()
-	{
-		var keywords =	'break case catch continue ' +
-						'default delete do else false  ' +
-						'for function if in instanceof ' +
-						'new null return super switch ' +
-						'this throw true try typeof var while with'
-						;
-
-		var r = SyntaxHighlighter.regexLib;
-		
-		this.regexList = [
-			{ regex: r.multiLineDoubleQuotedString,					css: 'string' },			// double quoted strings
-			{ regex: r.multiLineSingleQuotedString,					css: 'string' },			// single quoted strings
-			{ regex: r.singleLineCComments,							css: 'comments' },			// one line comments
-			{ regex: r.multiLineCComments,							css: 'comments' },			// multiline comments
-			{ regex: /\s*#.*/gm,									css: 'preprocessor' },		// preprocessor tags like #region and #endregion
-			{ regex: new RegExp(this.getKeywords(keywords), 'gm'),	css: 'keyword' }			// keywords
-			];
-	
-		this.forHtmlScript(r.scriptScriptTags);
-	};
-
-	Brush.prototype	= new SyntaxHighlighter.Highlighter();
-	Brush.aliases	= ['js', 'jscript', 'javascript'];
-
-	SyntaxHighlighter.brushes.JScript = Brush;
-
-	// CommonJS
-	typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
-})();
+(function(){function a(){var a=SyntaxHighlighter.regexLib;this.regexList=[{regex:a.multiLineDoubleQuotedString,css:"string"},{regex:a.multiLineSingleQuotedString,css:"string"},{regex:a.singleLineCComments,css:"comments"},{regex:a.multiLineCComments,css:"comments"},{regex:/\s*#.*/gm,css:"preprocessor"},{regex:new RegExp(this.getKeywords("break case catch continue default delete do else false  for function if in instanceof new null return super switch this throw true try typeof var while with"),"gm"),css:"keyword"}],this.forHtmlScript(a.scriptScriptTags)}a.prototype=new SyntaxHighlighter.Highlighter,a.aliases=["js","jscript","javascript"],SyntaxHighlighter.brushes.JScript=a,"undefined"==typeof exports?null:exports.Brush=a})();

+ 1 - 64
chrome/apps/static/vendor/syntaxhighlighter/shBrushSql.js

@@ -1,64 +1 @@
-/**
- * SyntaxHighlighter
- * http://alexgorbatchev.com/SyntaxHighlighter
- *
- * SyntaxHighlighter is donationware. If you are using it, please donate.
- * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
- *
- * @version
- * 3.0.83 (July 02 2010)
- * 
- * @copyright
- * Copyright (C) 2004-2010 Alex Gorbatchev.
- *
- * @license
- * Dual licensed under the MIT and GPL licenses.
- */
-;(function()
-{
-
-	function Brush()
-	{
-		var funcs	=	'abs avg case cast coalesce convert count current_timestamp ' +
-						'current_user day isnull left lower month nullif replace right ' +
-						'session_user space substring sum system_user upper user year';
-
-		var keywords =	'absolute action add after alter as asc at authorization begin bigint ' +
-						'binary bit by cascade char character check checkpoint close collate ' +
-						'column commit committed connect connection constraint contains continue ' +
-						'create cube current current_date current_time cursor database date ' +
-						'deallocate dec decimal declare default delete desc distinct double drop ' +
-						'dynamic else end end-exec escape except exec execute false fetch first ' +
-						'float for force foreign forward free from full function global goto grant ' +
-						'group grouping having hour ignore index inner insensitive insert instead ' +
-						'int integer intersect into is isolation key last level load local max min ' +
-						'minute modify move name national nchar next no numeric of off on only ' +
-						'open option order out output partial password precision prepare primary ' +
-						'prior privileges procedure public read real references relative repeatable ' +
-						'restrict return returns revoke rollback rollup rows rule schema scroll ' +
-						'second section select sequence serializable set size smallint static ' +
-						'statistics table temp temporary then time timestamp to top transaction ' +
-						'translation trigger true truncate uncommitted union unique update values ' +
-						'varchar varying view when where with work';
-
-		var operators =	'all and any between cross in join like not null or outer some';
-
-		this.regexList = [
-			{ regex: /--(.*)$/gm,												css: 'comments' },			// one line and multiline comments
-			{ regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString,	css: 'string' },			// double quoted strings
-			{ regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString,	css: 'string' },			// single quoted strings
-			{ regex: new RegExp(this.getKeywords(funcs), 'gmi'),				css: 'color2' },			// functions
-			{ regex: new RegExp(this.getKeywords(operators), 'gmi'),			css: 'color1' },			// operators and such
-			{ regex: new RegExp(this.getKeywords(keywords), 'gmi'),				css: 'keyword' }			// keyword
-			];
-	};
-
-	Brush.prototype	= new SyntaxHighlighter.Highlighter();
-	Brush.aliases	= ['sql'];
-
-	SyntaxHighlighter.brushes.Sql = Brush;
-
-	// CommonJS
-	typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
-})();
-
+(function(){function a(){this.regexList=[{regex:/--(.*)$/gm,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineDoubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.multiLineSingleQuotedString,css:"string"},{regex:new RegExp(this.getKeywords("abs avg case cast coalesce convert count current_timestamp current_user day isnull left lower month nullif replace right session_user space substring sum system_user upper user year"),"gmi"),css:"color2"},{regex:new RegExp(this.getKeywords("all and any between cross in join like not null or outer some"),"gmi"),css:"color1"},{regex:new RegExp(this.getKeywords("absolute action add after alter as asc at authorization begin bigint binary bit by cascade char character check checkpoint close collate column commit committed connect connection constraint contains continue create cube current current_date current_time cursor database date deallocate dec decimal declare default delete desc distinct double drop dynamic else end end-exec escape except exec execute false fetch first float for force foreign forward free from full function global goto grant group grouping having hour ignore index inner insensitive insert instead int integer intersect into is isolation key last level load local max min minute modify move name national nchar next no numeric of off on only open option order out output partial password precision prepare primary prior privileges procedure public read real references relative repeatable restrict return returns revoke rollback rollup rows rule schema scroll second section select sequence serializable set size smallint static statistics table temp temporary then time timestamp to top transaction translation trigger true truncate uncommitted union unique update values varchar varying view when where with work"),"gmi"),css:"keyword"}]}a.prototype=new SyntaxHighlighter.Highlighter,a.aliases=["sql"],SyntaxHighlighter.brushes.Sql=a,"undefined"==typeof exports?null:exports.Brush=a})();

+ 1 - 67
chrome/apps/static/vendor/syntaxhighlighter/shBrushXml.js

@@ -1,67 +1 @@
-/**
- * SyntaxHighlighter
- * http://alexgorbatchev.com/SyntaxHighlighter
- *
- * SyntaxHighlighter is donationware. If you are using it, please donate.
- * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
- *
- * @version
- * 3.0.83 (July 02 2010)
- * 
- * @copyright
- * Copyright (C) 2004-2010 Alex Gorbatchev.
- *
- * @license
- * Dual licensed under the MIT and GPL licenses.
- */
-;(function()
-{
-
-	function Brush()
-	{
-		function process(match, regexInfo)
-		{
-			var constructor = SyntaxHighlighter.Match,
-				code = match[0],
-				tag = new XRegExp('(&lt;|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)', 'xg').exec(code),
-				result = []
-				;
-		
-			if (match.attributes != null) 
-			{
-				var attributes,
-					regex = new XRegExp('(?<name> [\\w:\\-\\.]+)' +
-										'\\s*=\\s*' +
-										'(?<value> ".*?"|\'.*?\'|\\w+)',
-										'xg');
-
-				while ((attributes = regex.exec(code)) != null) 
-				{
-					result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
-					result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
-				}
-			}
-
-			if (tag != null)
-				result.push(
-					new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
-				);
-
-			return result;
-		}
-	
-		this.regexList = [
-			{ regex: new XRegExp('(\\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\&gt;|>)', 'gm'),			css: 'color2' },	// <![ ... [ ... ]]>
-			{ regex: SyntaxHighlighter.regexLib.xmlComments,												css: 'comments' },	// <!-- ... -->
-			{ regex: new XRegExp('(&lt;|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(&gt;|>)', 'sg'), func: process }
-		];
-	};
-
-	Brush.prototype	= new SyntaxHighlighter.Highlighter();
-	Brush.aliases	= ['xml', 'xhtml', 'xslt', 'html'];
-
-	SyntaxHighlighter.brushes.Xml = Brush;
-
-	// CommonJS
-	typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
-})();
+(function(){function a(){this.regexList=[{regex:new XRegExp("(\\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\&gt;|>)","gm"),css:"color2"},{regex:SyntaxHighlighter.regexLib.xmlComments,css:"comments"},{regex:new XRegExp("(&lt;|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(&gt;|>)","sg"),func:function(a){var b=SyntaxHighlighter.Match,c=a[0],d=new XRegExp("(&lt;|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)","xg").exec(c),e=[];if(null!=a.attributes)for(var f,g=new XRegExp("(?<name> [\\w:\\-\\.]+)\\s*=\\s*(?<value> \".*?\"|'.*?'|\\w+)","xg");null!=(f=g.exec(c));)e.push(new b(f.name,a.index+f.index,"color1")),e.push(new b(f.value,a.index+f.index+f[0].indexOf(f.value),"string"));return null!=d&&e.push(new b(d.name,a.index+d[0].indexOf(d.name),"keyword")),e}}]}a.prototype=new SyntaxHighlighter.Highlighter,a.aliases=["xml","xhtml","xslt","html"],SyntaxHighlighter.brushes.Xml=a,"undefined"==typeof exports?null:exports.Brush=a})();

File diff suppressed because it is too large
+ 0 - 16
chrome/apps/static/vendor/syntaxhighlighter/shCore.js


File diff suppressed because it is too large
+ 0 - 1225
chrome/apps/static/vendor/uglifyjs3/ast.js


File diff suppressed because it is too large
+ 0 - 6419
chrome/apps/static/vendor/uglifyjs3/compress.js


File diff suppressed because it is too large
+ 0 - 239
chrome/apps/static/vendor/uglifyjs3/minify.js


File diff suppressed because it is too large
+ 0 - 1915
chrome/apps/static/vendor/uglifyjs3/output.js


File diff suppressed because it is too large
+ 0 - 128
chrome/apps/static/vendor/uglifyjs3/parse.js


File diff suppressed because it is too large
+ 0 - 717
chrome/apps/static/vendor/uglifyjs3/scope.js


File diff suppressed because it is too large
+ 0 - 240
chrome/apps/static/vendor/uglifyjs3/script.js


File diff suppressed because it is too large
+ 0 - 269
chrome/apps/static/vendor/uglifyjs3/transform.js


File diff suppressed because it is too large
+ 0 - 346
chrome/apps/static/vendor/uglifyjs3/utils.js


+ 16 - 8
chrome/build.js

@@ -24,17 +24,27 @@ let copyFiles = function () {
 
 // js 文件压缩
 let jsCompress = function () {
+    console.log('> Javascript文件压缩 ...')
     console.time('> Javascript文件压缩');
+
     glob.sync('output/apps/**/*.js').map(cf => {
+        // 添加例外,有些js文件不用压缩
+        let exclude = /\/ga\.js|\/(codemirror|syntaxhighlighter|uglifyjs3)\/|.*\.min\.js|\/vue\.js/;
+        if (exclude.test(cf)) {
+            return false;
+        }
+
+        let start = new Date();
         let rawJs = fs.readFileSync(cf, 'utf8').toString();
         let compressedJs = jsMinifier(rawJs);
         if (compressedJs.code) {
             fs.writeFileSync(cf, compressedJs.code);
+            console.log('\t文件压缩成功,', ('耗时' + (new Date() - start) + 'ms').padEnd(12, ' '), cf);
         } else {
-            console.log('---------------------', cf, '----------------------');
-            console.log(compressedJs.error.message, '\n')
+            console.log('\t文件压缩失败:', cf);
         }
     });
+
     console.timeEnd('> Javascript文件压缩');
 };
 
@@ -72,29 +82,27 @@ let htmlCompress = function () {
     console.timeEnd('> HTML文件压缩');
 };
 
-// manifest文件压缩
-let manifestCompress = function () {
+// zip the fehelper
+let zipForChromeWebStore = function () {
+
     console.time('> Manifest文件压缩');
     let mf = './output/apps/manifest.json';
     let json = require(mf);
     fs.writeFileSync(mf, JSON.stringify(json));
     console.timeEnd('> Manifest文件压缩');
-};
 
-// zip the fehelper
-let zipForChromeWebStore = function () {
     console.time('> FeHelper打包');
     shell.cd(`${rootPath}/output`);
     shell.exec('zip -r fehelper.zip apps/ > /dev/null');
     console.timeEnd('> FeHelper打包');
     console.log('\n\n================================================================================');
+    console.log('    当前版本:', json.version);
     console.log('    去Chrome商店发布吧:https://chrome.google.com/webstore/devconsole');
     console.log('================================================================================\n\n');
 };
 
 /************************build start*****************************/
 copyFiles();
-manifestCompress();
 cssCompress();
 htmlCompress();
 jsCompress();

Some files were not shown because too many files changed in this diff