Skip to content

Commit 8cfbad2

Browse files
author
Jonathan Raoult
committed
Merge pull request mixtube#21 from jraoult/introduce_mainjs
Introduce main.js
2 parents 28151ab + 6a13115 commit 8cfbad2

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

app/index.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,7 @@ <h3>Results from {{pLabel}}:</h3>
304304
</div>
305305
</div>
306306

307-
<script src="scripts/app.js"></script>
308-
<script>
309-
initMixtube({youtubeAPIKey: '<!-- @echo YOUTUBE_API_KEY -->'});
310-
</script>
307+
<script src="scripts/main.js"></script>
311308
<script src="https://www.youtube.com/iframe_api" defer></script>
312309

313310
</body>

app/scripts/main.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
var mixtube = require('./mixtube');
4+
5+
mixtube({youtubeAPIKey: process.env.MIXTUBE_YOUTUBE_API_KEY});

app/scripts/app.js app/scripts/mixtube.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var angular = require('angular'),
1111
* @param {{track: function(event: string, data:= Object)}} [delegates.analyticsTracker]
1212
* @param {{track: function(error: Error)}} [delegates.errorsTracker]
1313
*/
14-
function initMixtube(environment, delegates) {
14+
function mixtube(environment, delegates) {
1515

1616
var _delegates = defaults({}, delegates, {
1717
analyticsTracker: {track: noop},
@@ -51,4 +51,4 @@ function initMixtube(environment, delegates) {
5151
});
5252
}
5353

54-
global.initMixtube = initMixtube;
54+
module.exports = mixtube;

gulpfile.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var path = require('path'),
2424
autoprefixer = require('autoprefixer'),
2525
csswring = require('csswring'),
2626
htmlreplace = require('gulp-html-replace'),
27-
preprocess = require('gulp-preprocess'),
2827
svgSprite = require('gulp-svg-sprite'),
2928
replace = require('gulp-replace'),
3029
svg2png = require('gulp-svg2png'),
@@ -49,6 +48,7 @@ function watchifiedSrc(src, baseDir, pipelineFn) {
4948
function doBundle() {
5049
return pipelineFn(
5150
b.bundle()
51+
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
5252
.pipe(source(path.relative(baseDir, src)))
5353
);
5454
}
@@ -108,12 +108,7 @@ function doInlineCss(opts) {
108108
}
109109

110110
function doHtml() {
111-
return gulp.src('app/index.html', {base: 'app'})
112-
.pipe(preprocess({
113-
context: {
114-
YOUTUBE_API_KEY: process.env.MIXTUBE_YOUTUBE_API_KEY
115-
}
116-
}));
111+
return gulp.src('app/index.html', {base: 'app'});
117112
}
118113

119114
function doFavicons(htmlCodeCb) {
@@ -190,7 +185,7 @@ gulp.task('js:dev', function() {
190185

191186
// generates the bundle and watches changes
192187
return merge(
193-
watchifiedSrc('./app/scripts/app.js', './app/scripts/', pipelineFn),
188+
watchifiedSrc('./app/scripts/main.js', './app/scripts/', pipelineFn),
194189
watchifiedSrc('./app/scripts/components/capabilities/videoCallPlayTest.js', './app/scripts/', pipelineFn));
195190
});
196191

@@ -242,7 +237,7 @@ gulp.task('css:dist', function() {
242237

243238
gulp.task('js:dist', function() {
244239
return merge(
245-
browserifiedSrc('./app/scripts/app.js', './app/scripts/'),
240+
browserifiedSrc('./app/scripts/main.js', './app/scripts/'),
246241
browserifiedSrc('./app/scripts/components/capabilities/videoCallPlayTest.js', './app/scripts/'))
247242
.pipe(buffer())
248243
.pipe(sourcemaps.init({loadMaps: true}))

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"compression": "^1.4.4",
2121
"csswring": "^4.0.0",
2222
"del": "^2.0.1",
23+
"envify": "^3.4.0",
2324
"favicons": "jraoult/favicons#add_html_callback_to_stream_api",
2425
"gulp": "^3.8.10",
2526
"gulp-gh-pages": "^0.5.2",
@@ -56,7 +57,8 @@
5657
},
5758
"browserify": {
5859
"transform": [
59-
"brfs"
60+
"brfs",
61+
"envify"
6062
]
6163
},
6264
"config": {

0 commit comments

Comments
 (0)