{"action":"closed","issue":{"url":"https://api.github.com/repos/mcfly-io/generator-sublime/issues/246","labels_url":"https://api.github.com/repos/mcfly-io/generator-sublime/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/mcfly-io/generator-sublime/issues/246/comments","events_url":"https://api.github.com/repos/mcfly-io/generator-sublime/issues/246/events","html_url":"https://github.com/mcfly-io/generator-sublime/issues/246","id":94811271,"number":246,"title":"'style' finishing before taskStyle() function finishes","user":{"login":"jskrzypek","id":1513265,"avatar_url":"https://avatars.githubusercontent.com/u/1513265?v=3","gravatar_id":"","url":"https://api.github.com/users/jskrzypek","html_url":"https://github.com/jskrzypek","followers_url":"https://api.github.com/users/jskrzypek/followers","following_url":"https://api.github.com/users/jskrzypek/following{/other_user}","gists_url":"https://api.github.com/users/jskrzypek/gists{/gist_id}","starred_url":"https://api.github.com/users/jskrzypek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jskrzypek/subscriptions","organizations_url":"https://api.github.com/users/jskrzypek/orgs","repos_url":"https://api.github.com/users/jskrzypek/repos","events_url":"https://api.github.com/users/jskrzypek/events{/privacy}","received_events_url":"https://api.github.com/users/jskrzypek/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mcfly-io/generator-sublime/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-13T21:03:26Z","updated_at":"2015-07-15T14:03:36Z","closed_at":"2015-07-15T14:03:36Z","body":"Browsersync (and possibly other tasks that rely on it) might not be getting the bundled css style files when they expect to. See the following gulp output:\r\n\r\n```sh\r\n[23:40:09] Starting 'image'...\r\n[23:40:09] Starting 'image:mxZI0'...\r\n[23:40:09] Finished 'image:mxZI0' after 6.67 ms\r\n[23:40:09] Finished 'image' after 15 ms\r\n[23:40:09] Finished 'style:watch' after 143 ms\r\n[23:40:09] Finished 'browsersync:G8jcu' after 274 ms\r\n[23:40:09] Finished 'browsersync' after 343 ms\r\n[23:40:09] gulp-imagemin: Minified 0 images\r\n[23:40:11] 'font:app' all files 1.43 MB\r\n[23:40:11] Finished 'font:ELWs0' after 2.84 s\r\n[23:40:11] Finished 'font' after 2.86 s\r\n[23:40:11] Starting 'style'...                      ## 'style' starts here\r\n[23:40:11] Starting 'style:AvmBr'...          ## gulp-mux wrapped taskStyle() starts\r\n[23:40:11] Finished 'style' after 26 ms    ## 'style' ends here\r\n[23:40:16] browserify 5868476 bytes written (7.02 seconds)\r\n[23:40:16] Finished 'watchify:F0lu8' after 7.49 s\r\n[23:40:16] Finished 'watchify' after 7.5 s\r\n[23:40:16] Starting 'browsersyncstart'...\r\n[23:40:16] Starting 'browsersyncstart:3YR8P'...\r\n[23:40:16] Launching ios emulator\r\n[23:40:16] Finished 'browsersyncstart:3YR8P' after 107 ms\r\n[23:40:16] Finished 'browsersyncstart' after 119 ms\r\n[BS] Access URLs:\r\n ----------------------------------\r\n       Local: http://localhost:5000\r\n    External: http://10.0.0.3:5000\r\n ----------------------------------\r\n          UI: http://localhost:3001\r\n UI External: http://10.0.0.3:3001\r\n ----------------------------------\r\n[BS] Serving files from: ./dist/app/dev/www\r\n[BS] Watching files...\r\n[23:40:20] 'css files' main.css 251.52 kB\r\n[23:40:20] Finished 'style:AvmBr' after 8.5 s      ## taskStyle() doesn't finish till all the way down here\r\n```\r\n\r\nThe problem likely stems from the fact that we are returning the stream rather than calling done() ourselves so we can't be sure when the task appears done to gulp. Gulp may also have a problem interpreting the returned values of `event-stream` streams as we use them in taskStyle()\r\n\r\nIf we wait for an actual 'end' event (using `es.wait()`) and then call done, we see this output: \r\n\r\n```sh\r\n[23:48:33] Starting 'image'...\r\n[23:48:33] Starting 'image:57BjU'...\r\n[23:48:33] Finished 'image:57BjU' after 7.24 ms\r\n[23:48:33] Finished 'image' after 24 ms\r\n[23:48:33] Finished 'style:watch' after 150 ms\r\n[23:48:33] Finished 'browsersync:0mq7h' after 278 ms\r\n[23:48:33] Finished 'browsersync' after 327 ms\r\n[23:48:33] gulp-imagemin: Minified 0 images\r\n[23:48:34] 'font:app' all files 1.43 MB\r\n[23:48:34] Finished 'font:Ne3CE' after 1.8 s\r\n[23:48:34] Finished 'font' after 1.8 s\r\n[23:48:34] Starting 'style'...                                        ## 'style' starts\r\n[23:48:34] Starting 'style:DxIhX'...                             ## taskStyle() starts\r\n[23:48:38] browserify 5868476 bytes written (5.42 seconds)\r\n[23:48:38] 'css files' main.css 251.52 kB\r\n[23:48:38] Finished 'style:DxIhX' after 4.19 s          ## taskStyle() ends\r\n[23:48:38] Finished 'style' after 4.2 s                       ## 'style' ends\r\n[23:48:38] Finished 'watchify:90rTO' after 6.06 s\r\n[23:48:38] Finished 'watchify' after 6.07 s\r\n[23:48:38] Starting 'browsersyncstart'...\r\n[23:48:38] Starting 'browsersyncstart:TTAdB'...\r\n[23:48:38] Launching ios emulator\r\n[23:48:38] Finished 'browsersyncstart:TTAdB' after 110 ms\r\n[23:48:38] Finished 'browsersyncstart' after 120 ms\r\n[BS] Access URLs:\r\n ----------------------------------\r\n       Local: http://localhost:5000\r\n    External: http://10.0.0.3:5000\r\n ----------------------------------\r\n          UI: http://localhost:3001\r\n UI External: http://10.0.0.3:3001\r\n ----------------------------------\r\n[BS] Serving files from: ./dist/app/dev/www\r\n[BS] Watching files...\r\n```\r\n\r\nThis is the fixed code:\r\n\r\n```js\r\nvar taskStyle = function(constants, done) {\r\n    var dest = constants.dist.distFolder;\r\n    dest = helper.isMobile(constants) ? dest + '/www/' + constants.style.dest : dest + '/' + constants.style.dest;\r\n\r\n    var sassFiles = gulp.src(constants.style.sass.src)\r\n        .pipe(sass({\r\n            errLogToConsole: false,\r\n            onError: function(err) {\r\n                gutil.beep();\r\n                gutil.log(gutil.colors.red('Sass failed'));\r\n                gutil.log(gutil.colors.red(err.message));\r\n                gutil.log(gutil.colors.red(err.file + ':' + err.line + ':' + err.column));\r\n            }\r\n        }))\r\n        .pipe(concat('sass.css'));\r\n\r\n    var lessFiles = gulp.src(constants.style.less.src)\r\n        .pipe(less())\r\n        .pipe(concat('less.css'));\r\n\r\n    es.concat(lessFiles, sassFiles)\r\n        .pipe(order(['less.css', 'sass.css']))\r\n        .pipe(concat(constants.style.destName))\r\n        .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))\r\n        .pipe(gulpif(constants.mode === 'prod', minifycss()))\r\n        .pipe(gulp.dest(dest))\r\n        .pipe($.size({\r\n            title: 'css files',\r\n            showFiles: true\r\n        }))\r\n        .pipe(es.wait(done));\r\n};\r\n\r\ngulp.task('style', 'Generates a bundle for style files.', ['font'], function(done) {\r\n    var taskname = 'style';\r\n    gmux.targets.setClientFolder(constants.clientFolder);\r\n    if (global.options === null) {\r\n        global.options = gmux.targets.askForMultipleTargets(taskname);\r\n    }\r\n    gmux.createAndRunTasks(gulp, taskStyle, taskname, global.options.target, global.options.mode, constants, done);\r\n});\r\n```"}}