Split vendor and site assets

This commit is contained in:
Oliver Davies 2016-02-03 19:24:47 +00:00
parent 9361a4cdf9
commit eeb532b809
9 changed files with 56 additions and 27 deletions

View file

@ -1,4 +1,4 @@
g = require 'gulp'
g.task 'build', ->
g.start 'clean', 'styles', 'scripts', 'fonts'
g.start 'clean', 'vendor', 'styles', 'fonts'

View file

@ -1,5 +1,11 @@
g = require 'gulp'
g.task 'clean', ->
g.src "{output_*,source}/assets/{css,fonts,js}", read: false
g.src [
'output_*/assets/css',
'output_*/assets/fonts',
'source/assets/css',
'source/assets/fonts',
'source/assets/js',
], read: false
.pipe g.p.clean()

View file

@ -1,10 +0,0 @@
g = require 'gulp'
g.task 'scripts', =>
g.src ['vendor/bower/jquery/dist/jquery.js', 'vendor/bower/bootstrap-sass/assets/javascripts/bootstrap.js']
.pipe g.p.plumber()
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init()
.pipe g.p.concat 'all.js'
.pipe g.p.if g.config.production, g.p.uglify()
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.')
.pipe g.dest 'source/assets/js'

View file

@ -1,11 +1,4 @@
g = require 'gulp'
g.task 'styles', ->
g.src ['vendor/bower/font-awesome/css/font-awesome.css', 'sass/styles.scss']
.pipe g.p.plumber()
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init()
.pipe g.p.sass()
.pipe g.p.concat 'all.css'
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.')
.pipe g.dest 'source/assets/css'
.pipe g.p.if g.config.livereload, g.p.livereload()
g.css 'sass/site.scss', 'site.css'

15
gulp/vendor.coffee Normal file
View file

@ -0,0 +1,15 @@
g = require 'gulp'
g.task 'vendor', -> g.start 'vendor-styles', 'vendor-scripts'
g.task 'vendor-styles', ->
g.css [
'sass/vendor.scss',
'vendor/bower/font-awesome/css/font-awesome.css'
], 'vendor.css'
g.task 'vendor-scripts', =>
g.js [
'vendor/bower/jquery/dist/jquery.js',
'vendor/bower/bootstrap-sass/assets/javascripts/bootstrap/collapse.js',
], 'vendor.js'

View file

@ -11,7 +11,26 @@ g.config =
liveReload: !g.p.util.env.production
g.copy = (srcFiles, outputDir) ->
g.src(srcFiles)
.pipe g.dest(outputDir)
g.src srcFiles
.pipe g.dest outputDir
g.css = (srcFiles, destFile) ->
g.src srcFiles
.pipe g.p.plumber()
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init()
.pipe g.p.sass()
.pipe g.p.concat destFile
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.')
.pipe g.dest 'source/assets/css'
.pipe g.p.if g.config.livereload, g.p.livereload()
g.js = (srcFiles, destFile) ->
g.src srcFiles
.pipe g.p.plumber()
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.init()
.pipe g.p.concat destFile
.pipe g.p.if g.config.production, g.p.uglify()
.pipe g.p.if g.config.sourceMaps, g.p.sourcemaps.write('.')
.pipe g.dest 'source/assets/js'
require('fs').readdirSync('./gulp').forEach (task) -> require "./gulp/#{task}"

View file

@ -1,7 +1,8 @@
@import '_variables';
@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap/variables';
@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap/mixins/clearfix';
@import '../vendor/bower/compass-breakpoint/stylesheets/breakpoint';
@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap';
@import '_variables';
@import 'partials/base';
@import 'partials/badges';

4
sass/vendor.scss Normal file
View file

@ -0,0 +1,4 @@
@import '_variables';
@import '../vendor/bower/compass-breakpoint/stylesheets/breakpoint';
@import '../vendor/bower/bootstrap-sass/assets/stylesheets/bootstrap';

View file

@ -18,7 +18,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ site.url }}/assets/css/all.css">
<link rel="stylesheet" href="{{ site.url }}/assets/css/vendor.css">
<link rel="stylesheet" href="{{ site.url }}/assets/css/site.css">
{% block styles %}{% endblock %}
{% for size in site.apple_touch_icon_sizes %}
@ -90,7 +91,7 @@
{% include('meetups') %}
</footer>
<script src="{{ site.url }}/assets/js/all.js"></script>
<script src="{{ site.url }}/assets/js/vendor.js"></script>
{% block scripts %}{% endblock %}