Dan Dan - 1 year ago 106
AngularJS Question

AngularJS + Gulp files and folders structure and right gulpfule.js config

I want to create a three page app, i need follow structure:


public (for production version)


How should i create a tasks for scripts (scripts in different folders) in gulpfile.js?

Maybe my structure is wrong, then how could it to look like?

Answer Source

Your structure seems right. You can use any architecture you want for your project. Regarding Gulp, you just have to know how to filter the javascript source files when you call gulp.src(). It should be something like this:

gulp.task('scripts', function() {
    return gulp.src('./app/**/*.js')
        .pipe() //Do whatever process you need here

A quick recommendation would be to create a gulp.config.js file to handle all the string variables, filters, directories, among others. Then require it in your gulpfile.js and use those variables to provide a cleaner code. It should be something around this:

gulp.config.js (located in the same folder of the gulpfile.js)

module.exports = function() {
    var src = './app/';
    var dest = './assets/';

    var config = {
        js: {
            src: src + '**/*.js',
            dest: dest + 'js/'

    return config;


var config = require('./gulp.config.js')();


gulp.task('scripts', function() {
    return gulp.src(config.js.src)
        .pipe() //Do whatever process you need here

This should work for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download