From 1e164ba83b85ae5026633f4fde3c5ee245aac1ea Mon Sep 17 00:00:00 2001 From: Jakub Gutkowski Date: Mon, 6 Oct 2014 02:17:25 +0200 Subject: [PATCH] the most ugly fix for issue i have ever created fixes #32 with inline javascript code that handles http* and file protocol so ACE will know where to look for files --- README.md | 3 +++ gulpfile.js | 39 +++++++++++++++++++++++++++++++++++++-- src/js/bootstrap.js | 2 ++ src/js/main.js | 2 ++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71d05b59..b9e9cde6 100644 --- a/README.md +++ b/README.md @@ -53,4 +53,7 @@ gulp html // building project - creating minified version of css, js etc. gulp dist + +// if dist has been build, connect-dist will do same as connect but for dist folder. +gulp connect-dist ``` diff --git a/gulpfile.js b/gulpfile.js index 9c9ad11a..85ada283 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -76,6 +76,8 @@ var rjsOpts = { 'sprintf': '../bower_components/sprintf/src/sprintf', 'uiAce': '../bower_components/angular-ui-ace/ui-ace', 'ace': '../bower_components/ace-builds/src-min-noconflict/ace', + //'ace-js': '../bower_components/ace-builds/src-min-noconflict/mode-javascript', + //'ace-monokai': '../bower_components/ace-builds/src-min-noconflict/theme-monokai', 'es-ui': './app' } }; @@ -124,9 +126,33 @@ gulp.task('dist-js', function () { .pipe(uglify()) .pipe(gulp.dest('./es-dist/js/')); + // copy ace, do not try to minify it :/ + gulp.src('./src/bower_components/ace-builds/src-min-noconflict/*') + //.pipe(uglify()) + .pipe(gulp.dest('./es-dist/js/ace')); + + // can't figure out better option of doing it :( rjs(rjsOpts) - .pipe(insert.append('require(["bootstrap"]);')) - .pipe(uglify()) + .pipe(insert.append(';\n\r'+ + + 'define("es-dist-main", ["bootstrap", "ace"], function (_i, _a) {\n\r'+ + ' var _c = ace.require("ace/config");\n\r'+ + ' _c.set("packaged",true);\n\r'+ + ' var _aa_cfg_dist_path = "js/ace";\n\r'+ + ' _c.set("workerPath", location.href.replace(location.hash, "").replace("index.html", "") + "/" + _aa_cfg_dist_path);\n\r'+ + ' _c.set("modePath", _aa_cfg_dist_path);\n\r'+ + ' _c.set("themePath", _aa_cfg_dist_path);\n\r'+ + ' _c.set("basePath", _aa_cfg_dist_path);\n\r'+ + '});\n\r'+ + + 'require(["es-dist-main"]);\n\r'+ + '')) + // .pipe(insert.append(';require(["bootstrap"]);')) + // .pipe(insert.append('; var _aa_cfg_dist = require("ace/config");' + + // '_aa_cfg_dist.set("packaged",true);' + + // 'var _aa_cfg_dist_path = "js/ace";' + + // '_aa_cfg_dist.set("basePath", _aa_cfg_dist_path);')) + // .pipe(uglify()) .pipe(gulp.dest('./es-dist/js/')); }); @@ -256,4 +282,13 @@ gulp.task('connect', connect.server({ } })); +gulp.task('connect-dist', connect.server({ + root: ['es-dist'], + port: 8888, + livereload: true, + open: { + browser: 'chrome' + } +})); + gulp.task('default', ['dev']); diff --git a/src/js/bootstrap.js b/src/js/bootstrap.js index 3790b0d2..230ca18d 100644 --- a/src/js/bootstrap.js +++ b/src/js/bootstrap.js @@ -3,6 +3,8 @@ define([ 'angular', 'es-ui', 'run', + //'ace-js', + //'ace-monokai', './config/constants', './config/urls', './config/values', diff --git a/src/js/main.js b/src/js/main.js index 22cdb206..c42e84f6 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -11,6 +11,8 @@ require.config({ 'sprintf': '../bower_components/sprintf/src/sprintf', 'uiAce': '../bower_components/angular-ui-ace/ui-ace', 'ace': '../bower_components/ace-builds/src-min-noconflict/ace', + //'ace-js': '../bower_components/ace-builds/src-min-noconflict/mode-javascript', + //'ace-monokai': '../bower_components/ace-builds/src-min-noconflict/theme-monokai', 'es-ui': './app' }, shim: {