Permalink
Browse files

- Fixed gulp build

- Moved all the inline source in index.html to external files, and inlining them for builds.
  • Loading branch information...
1 parent 14e3439 commit 8fdb621dcd645185f67ad8238d6224950695e780 @wdamien wdamien committed Jan 20, 2016
Showing with 41 additions and 33 deletions.
  1. +18 −7 gulpfile.js
  2. +2 −23 index.html
  3. +7 −0 js/analytics.template.js
  4. +11 −0 js/checkSupport.template.js
  5. +3 −3 package.json
View
@@ -7,7 +7,7 @@ var connect = require('gulp-connect');
var open = require('gulp-open');
var minifyCss = require('gulp-minify-css');
var rimraf = require('gulp-rimraf');
-var inline = require('gulp-inline');
+var inline = require('gulp-inline-source');
var template = require('gulp-template');
var minifyHTML = require('gulp-minify-html');
var source = require('vinyl-source-stream');
@@ -72,10 +72,13 @@ gulp.task('watch-js-templates', function () {
return gulp.watch(assets, ['copy-js-templates']);
});
-gulp.task('copy-js-templates', function () {
+gulp.task('copy-js-templates', function (cb) {
var assets = "js/*.template.js";
- return gulp.src(assets, {base: './js'})
- .pipe(gulp.dest('build/js/'));
+ gulp.src(assets, {base: './js'})
+ .pipe(gulp.dest('build/js/'))
+ .on("finish", function() {
+ cb();
+ });
});
gulp.task('watch-assets', function () {
@@ -136,7 +139,12 @@ gulp.task('clean-pre-build', function () {
});
gulp.task('clean-post-build', function () {
- return gulp.src(['./build/js/index.template.js', './build/js/scripts.min.js.map'], {read: false})
+ return gulp.src([
+ './build/js/index.template.js',
+ './build/js/scripts.min.js.map',
+ './build/js/checkSupport.template.js',
+ './build/js/analytics.template.js'
+ ], {read: false})
.pipe(rimraf());
});
@@ -160,8 +168,11 @@ gulp.task('build', function (done) {
runSequence(
'clean-pre-build',
['build-js', 'copy-assets', 'sass'],
- ['minify-js', 'minify-css', 'inline'],
- ['parse-index', 'clean-post-build'],
+ 'copy-js-templates',
+ ['minify-js', 'minify-css'],
+ ['parse-index'],
+ 'inline',
+ 'clean-post-build',
'server', 'open-build',
done
);
View
@@ -371,29 +371,8 @@ <h1 class="regexr-text">RegExr</h1><span class="version regexr-text">v2.1</span>
To fix showing the "Not supported" screen in IE 7 (and other old browsers).
Since our initial load can cause errors, we just catch them and show the overlay if they happen.
-->
-<script>
- var el;
- if (!$.isSupported()) {
- el = document.querySelector(".not-supported");
- $.removeClass(el, "hidden");
- } else if($.partialSupport()) {
- el = document.querySelector(".not-supported-mobile");
- $.removeClass(el, "hidden");
- $.el("#closeOverlay").addEventListener("click", function() {
- $.addClass(el, "hidden");
- });
- }
-</script>
-
-<script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-3579542-6', 'regexr.com');
- ga('send', 'pageview', '/');
-</script>
+<script src="js/checkSupport.template.js" inline></script>
+<script src="js/analytics.template.js" inline></script>
<script src="js/index.template.js" inline></script>
</body>
@@ -0,0 +1,7 @@
+(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ga('create', 'UA-3579542-6', 'regexr.com');
+ga('send', 'pageview', '/');
@@ -0,0 +1,11 @@
+var el;
+if (!$.isSupported()) {
+ el = document.querySelector(".not-supported");
+ $.removeClass(el, "hidden");
+} else if($.partialSupport()) {
+ el = document.querySelector(".not-supported-mobile");
+ $.removeClass(el, "hidden");
+ $.el("#closeOverlay").addEventListener("click", function() {
+ $.addClass(el, "hidden");
+ });
+}
View
@@ -1,18 +1,18 @@
{
"name": "RegExr",
- "version": "2.0.0",
+ "version": "2.1.0",
"license": "MIT",
"repository": "http://github.com/gskinner/regexr/regexr.git",
"devDependencies": {
"browser-sync": "^2.10.0",
"browserify": "^10.2.6",
"gulp": "^3.9.0",
- "gulp-open": "^1.0.0",
"gulp-compass": "^2.1.0",
"gulp-connect": "^2.2.0",
- "gulp-inline": "^0.1.0",
+ "gulp-inline-source": "^2.1.0",
"gulp-minify-css": "^1.2.1",
"gulp-minify-html": "^1.0.4",
+ "gulp-open": "^1.0.0",
"gulp-rimraf": "^0.2.0",
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",

0 comments on commit 8fdb621

Please sign in to comment.