Permalink
Browse files

Complete overhaul of the build system; Switched to use Browserify, sw…

…itched some third-party libs to npm, updated npm's devDependencies to their latest versions. Changed to use only UglifyJS for our JS minifier.
  • Loading branch information...
1 parent 5c8f387 commit a37be67738f07bf9f4c0e66cc890e81e0cf1649c @wdamien wdamien committed with wdamien May 26, 2015
Showing with 5,326 additions and 14,926 deletions.
  1. +1 −0 .gitignore
  2. +66 −128 Gruntfile.js
  3. BIN assets/ZeroClipboard.swf
  4. +11 −63 index.html
  5. +69 −66 js/BrowserHistory.js
  6. +142 −122 js/ExpressionHighlighter.js
  7. +91 −81 js/ExpressionHover.js
  8. +50 −51 js/RegExJS.js
  9. +318 −292 js/RegExLexer.js
  10. +28 −0 js/RegExr.js
  11. +114 −111 js/Settings.js
  12. +139 −120 js/SourceHighlighter.js
  13. +102 −89 js/SubstLexer.js
  14. +38 −41 js/Tracking.js
  15. +234 −224 js/controls/List.js
  16. +122 −122 js/controls/Rating.js
  17. +222 −214 js/controls/TagInput.js
  18. +230 −216 js/controls/Tooltip.js
  19. +1 −4 js/documentation.js
  20. +11 −13 js/events/DataEvent.js
  21. +209 −213 js/events/Event.js
  22. +334 −298 js/events/EventDispatcher.js
  23. +117 −117 js/events/TransitionEvents.js
  24. +68 −67 js/index.template.js
  25. +28 −30 js/net/CommunityModel.js
  26. +104 −100 js/net/ExpressionModel.js
  27. +154 −157 js/net/ServerModel.js
  28. +60 −61 js/net/TagsModel.js
  29. +1 −1 js/regExWorker.template.js
  30. +0 −1,010 js/third-party/ZeroClipboard.js
  31. +0 −176 js/third-party/classList.js
  32. +0 −7,601 js/third-party/codemirror.js
  33. +0 −960 js/third-party/es6-promise-2.0.1.js
  34. +0 −167 js/third-party/store.js
  35. +44 −34 js/utils/CMUtils.js
  36. +123 −94 js/utils/Docs.js
  37. +23 −21 js/utils/TextUtils.js
  38. +95 −82 js/utils/Utils.js
  39. +120 −115 js/views/Community.js
  40. +658 −548 js/views/DocView.js
  41. +393 −377 js/views/Favorites.js
  42. +68 −61 js/views/FlagsMenu.js
  43. +225 −201 js/views/LibView.js
  44. +235 −231 js/views/SaveMenu.js
  45. +193 −192 js/views/ShareMenu.js
  46. +25 −8 package.json
  47. +0 −47 scripts.json
  48. +60 −0 tasks/grunt-inline-source.js
View
@@ -29,3 +29,4 @@ build/
_db.php
regexr.css
*.map
+scripts.min.js
View
@@ -2,84 +2,75 @@ var path = require("path");
var uglify = require("uglify-js");
module.exports = function (grunt) {
- /*
- Load all the tasks we need
- */
-
- /*
- *************************************
- **** About: grunt-yui-compressor ****
- *************************************
- Usually we use uglifyJS for code minification.
- However uglify breaks the Unicode characters Codemirror uses in its RegEx expressions,
- whereas yui does not.
- */
- grunt.loadNpmTasks("grunt-yui-compressor");
- grunt.loadNpmTasks("grunt-contrib-watch");
- grunt.loadNpmTasks("grunt-contrib-uglify");
- grunt.loadNpmTasks("grunt-contrib-sass");
- grunt.loadNpmTasks("grunt-contrib-connect");
- grunt.loadNpmTasks("grunt-contrib-clean");
- grunt.loadNpmTasks("grunt-contrib-htmlmin");
- grunt.loadNpmTasks("grunt-contrib-copy");
- grunt.loadNpmTasks("grunt-contrib-concat");
- grunt.loadNpmTasks('grunt-browser-sync');
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
deployFolder: "build/",
- // YUI-min
- min: {
- options: {
- report: false
- },
- build: {
- src: getScripts().yui,
- dest: "<%= deployFolder %>js/yui.min.js"
- }
- },
-
uglify: {
options: {
compress: {
global_defs: {
DEBUG: false
},
dead_code: true
- }
+ },
+ // Required so uglify doesn't break our Unicode characters.
+ ASCIIOnly: true
},
build: {
files: {
- "<%= deployFolder %>js/uglify.min.js":getScripts().uglify,
- "<%= deployFolder %>js/regExWorker.template.js":"js/regExWorker.template.js"
+ "<%= deployFolder %>js/scripts.min.js": 'js/scripts.min.js',
+ '<%= deployFolder %>js/regExWorker.template.js': 'js/regExWorker.template.js'
}
}
},
- concat: {
- build: {
- src: ["<%= deployFolder %>js/yui.min.js", "<%= deployFolder %>js/uglify.min.js"],
- dest: "<%= deployFolder %>js/scripts.min.js",
- }
- },
-
sass: {
- build:{
+ build: {
options: {
compass: true,
- style: "compact", // Can be nested, compact, compressed, expanded
+ style: "compressed", // Can be nested, compact, compressed, expanded
precision: 2,
},
files: {
- "css/regexr.css":"scss/regexr.scss"
+ "css/regexr.css": "scss/regexr.scss"
}
}
},
+ browserify: {
+ build: {
+ files: {
+ 'js/scripts.min.js': ['js/RegExr.js'],
+ }
+ },
+ run: {
+ files: {
+ 'js/scripts.min.js': ['js/RegExr.js'],
+ },
+ options: {
+ watch: true,
+ keepAlive: false
+ }
+ },
+ },
+
+ inline: {
+ build: {
+ files: [
+ {
+ cwd: './',
+ src: 'index.html',
+ dest: 'build/index.html',
+ }
+ ]
+ }
+ },
+
browserSync: {
bsFiles: {
- src: ["css/*.css", "js/**/.js", "index.html"]
+ src: ["css/*.css", "js/scripts.min.js", "js/*.template.js", "index.html"]
},
options: {
server: {
@@ -96,23 +87,14 @@ module.exports = function (grunt) {
},
},
- cssmin: {
- options: {
- report: false
- },
- build: {
- src: "css/regexr.css",
- dest: "<%= deployFolder %>css/regexr.css"
- }
- },
-
copy: {
build: {
files: [
{
expand: true,
- src:[
+ src: [
"assets/**",
+ "css/regexr.css",
"php/**",
"*.ico",
".htaccess",
@@ -128,106 +110,62 @@ module.exports = function (grunt) {
build: {
options: {
hostname: "*",
- keepalive:true,
+ keepalive: true,
useAvailablePort: true,
open: true,
base: './build/'
}
}
},
- htmlmin: {
- options: {
- removeComments: true,
- collapseWhitespace: true
- },
- build: {
- files:[{src: "<%= deployFolder %>index.html.tmp", dest: "<%= deployFolder %>index.html"}],
- }
- },
-
clean: {
- build: ["<%= deployFolder %>!(v1|.git|php|sitemap.txt|*.md)**"],
- postBuild: ["<%= deployFolder %>**/*.tmp", "<%= deployFolder %>js/yui.min.js", "<%= deployFolder %>js/uglify.min.js"]
+ build: ["<%= deployFolder %>!(v1|.git|php|sitemap.txt|*.md)**"]
}
});
+ /*
+ Load all the tasks we need
+ */
+ grunt.loadNpmTasks("grunt-contrib-uglify");
+ grunt.loadNpmTasks("grunt-contrib-watch");
+ grunt.loadNpmTasks("grunt-contrib-sass");
+ grunt.loadNpmTasks("grunt-contrib-connect");
+ grunt.loadNpmTasks("grunt-contrib-clean");
+ grunt.loadNpmTasks("grunt-contrib-copy");
+ grunt.loadNpmTasks('grunt-browser-sync');
+ grunt.loadNpmTasks('grunt-browserify');
+ grunt.loadTasks('tasks/');
+
/**
* Runs the index.html file through grunts template system.
*
*/
grunt.registerTask("parse-index", function (type) {
- var templateFile = grunt.file.read("index.html");
- var indexJs = minifyJS(grunt.file.read("js/index.template.js"));
-
- var buildIndexTag = "\n"+indexJs+"";
-
- var output = grunt.template.process(templateFile, {data:{build:true, index:buildIndexTag, noCache:Date.now()}})
+ var templateFile = grunt.file.read("build/index.html");
+ var output = grunt.template.process(templateFile, {
+ data: {
+ noCache: Date.now()
+ }
+ })
- //Write a temp html file, the htmlmin task will minify it to index.html
- grunt.file.write(grunt.config.get("deployFolder")+"index.html.tmp", output);
+ grunt.file.write(grunt.config.get("deployFolder") + "index.html", output);
});
grunt.registerTask("default", [
"sass",
+ "browserify",
"browserSync",
- "watch",
+ "watch"
]);
grunt.registerTask("build", [
"clean:build",
"sass",
- "cssmin",
- "min",
+ "browserify",
"uglify",
- "concat",
+ "inline",
"parse-index",
- "htmlmin",
"copy",
- "clean:postBuild",
"connect:build"
]);
-
- /**
- * Loads our scripts.json file.
- *
- */
- function getScripts() {
- var scripts = grunt.file.readJSON("scripts.json");
- var missing = [];
- for (var n in scripts) {
- var arr = scripts[n];
- arr.forEach(function(item, index, array) {
- if (!grunt.file.exists(item)) {
- missing.push(n+": "+item);
- }
- });
- }
-
- if (missing.length) {
- // \x07 == beep sound in the terminal.
- grunt.log.warn("\x07Missing ", missing.length + " scripts.\n\t" + missing.join("\n\t"));
- }
-
- return scripts;
- }
-
- /**
- * Utility function.
- * Returns an minified version of a javascript string, file or files.
- *
- * @param script {String|Array} Either a Javascript string,
- * or an array of paths to Javascript files.
- *
- * Returns a minified version of the script(s) passed in.
- */
- function minifyJS(script) {
- var uglifyConfig = {};
- if (typeof script == "string") {
- uglifyConfig.fromString = true;
- }
-
- var result = uglify.minify(script, uglifyConfig);
- return result.code;
- }
};
Binary file not shown.
Oops, something went wrong.

0 comments on commit a37be67

Please sign in to comment.