mikestreety / gulp

A starting gulp file and package.json
123 stars 17 forks source link

Couple questions #4

Closed nmaxcom closed 9 years ago

nmaxcom commented 9 years ago

Hi!

I'm a bit gulp noob so I wanted to ask, how do you make sure that your CSS files are concatenated in order? Same with JS?

Also, when you are developing an index.html for example, with its reference tags for example:

<script src="script1.js"></script>
<script src="script2.js"></script>
<script src="script3.js"></script>

Can you automate it with gulp so that it automatically changes it to something like

<script src="allscripts.min.js"></script>

I tried with a couple plugins but they seem not to work properly. How do you face this issue? Do you change them by hand?

Thank you Mike!

mikestreety commented 9 years ago

Hi,

With this gulp script, that is what the appFiles and vendor files variables are for. Consider your example and imagine all those js scripts were in your app/js folder but you also wanted to include jQuery which is in a lib/js folder. The top of your gulpfile would look like:

var appFiles = {
    styles: paths.styles.src + '**/*.scss',
    scripts: [
        'app/js/script1.js',
        'app/js/script2.js',
        'app/js/script3.js'
    ]
};

var vendorFiles = {
    styles: '',
    scripts: ['lib/js/jquery.js']
};

You can see on line 92 that gulp concatenates your app files on the end of your vendor files.

As for the sass, i would include the lib files at the top of your main style.scss.

Hope that helps!