ionic serve custom gulp commands
So I really like the mechanism to execute the sass and watch gulp tasks when serving the application. I was wondering if this could be expanded so any gulp task could be executed as a prerequisite to running the ionic serve command?
Maybe the sass flag in the ionic project file needs to be called something more generic like preserveor build giving the user the option of referencing multiple gulp tasks in their gulpfile?
{
"name": "myApp",
"app_id": "",
"preserve": true
}
gulp.task('preserve', ['sass', 'angular-templates'])
In most use-cases it's not just sass which needs a preprocessing step, images, templates etc sometimes need to be passed through a gulp task. At present my work around is to declare sass: true in the ionic project file and amend the watch task to run:
gulp.task('watch', ['angular-templates'], function() {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.templates, ['angular-templates']);
});
Of course this means in order for the watch task to be executed the sass: true flag is required.
On feedback, i'd be happy to submit a pull req.
+1 to this, I'd like to integrate usemin into ionic projects, but the ionic cli specifically targets the watch/sass gulp commands with no customization possibilities. (https://github.com/driftyco/ionic-cli/blob/master/lib/ionic/serve.js#L124)
This would also need to be possible in the actual building ofcourse, even more so than in serve.
Especially when you split all your controllers/directives/services/... you want to get these concatted/minified in 1 file (preferably through usemin)
So for the gulp file, the thought has been that we're providing the basic gulp setup and developers can customize it to their needs.
But in your case, the sass: true property is too specific, and instead we could have a someproperty: ["sass", "watch"] property that ionic serve would reference when it starts. So by default the CLI would be setup for gulp to run sass and watch, but this could be changed.
Would this accomplish what you're looking for? Also, what's a good name for this property, i'm struggling to come up with something that makes sense. For reference, this is where the gulp commands would run when ionic serve starts up: https://github.com/driftyco/ionic-cli/blob/master/lib/ionic/serve.js#L122
How about gulpStartupTasks?
gulpStartupTasks sounds good to me.
As long as we can specify custom gulp tasks, it would accomplish any needs, I believe. Name wise I can never decide either, so I'll pass on that :smile:
Kind of offtopic:
It might get a bit messy in the www folder, considering you'd have a source and dist - similar to most web apps - when you start integrating usemin, concatinators, ...
Currently ionic's scss sits outside the www folder too. Maybe there needs to be a standard for this, even tho this is somewhat personal preference, a good base structure is always a blessing.
+1
This is now in the v1.2.4 release, thanks!