Skip to content

Commit

Permalink
Merge pull request #5 from chmontgomery/feature/gulp-rev
Browse files Browse the repository at this point in the history
Feature/gulp rev
  • Loading branch information
chmontgomery committed Jul 29, 2014
2 parents 902e7b5 + 1a20192 commit 434d9ba
Show file tree
Hide file tree
Showing 41 changed files with 119 additions and 89 deletions.
8 changes: 6 additions & 2 deletions examples/bower/bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ module.exports = {
'./bower_components/bootstrap/dist/css/bootstrap-theme.css'
],
options: {
uglify: false // don't minify js since bower already ships with one
uglify: false, // don't minify js since bower already ships with one
rev: false
}
},
main: {
scripts: [
'./content/js/one.js',
'./content/js/two.js'
],
styles: './content/**/*.css'
styles: './content/**/*.css',
options: {
rev: false
}
}
},
copy: {
Expand Down
4 changes: 2 additions & 2 deletions examples/express-app-using-result-json/bundle.result.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"main": {
"styles": "<link href='main.css' media='screen' rel='stylesheet' type='text/css'/>",
"scripts": "<script src='main.js' type='text/javascript'></script>"
"styles": "<link href='main-8e6d79da.css' media='screen' rel='stylesheet' type='text/css'/>",
"scripts": "<script src='main-5f17cd21.js' type='text/javascript'></script>"
}
}
14 changes: 9 additions & 5 deletions examples/per-environment/bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@ module.exports = {
},
options: {
uglify: false, // never minify
rev: false,
useMin: ['production', 'staging'] // use pre-minified src only on prod and staging
}
},
one: {
scripts: './content/js/one.js',
options: {
uglify: 'staging' // minify ONLY when NODE_ENV=staging
uglify: 'staging', // minify ONLY when NODE_ENV=staging
rev: 'staging'
}
},
two: {
scripts: './content/js/two.js',
options: {
uglify: ['production', 'staging'] // minify ONLY when NODE_ENV=staging or NODE_ENV=production
uglify: ['production', 'staging'], // minify ONLY when NODE_ENV=staging or NODE_ENV=production
rev: ['production', 'staging']
}
},
threve: {
scripts: './content/js/threve.js',
threeve: {
scripts: './content/js/threeve.js',
options: {
uglify: true // minify in all environments
uglify: true, // minify in all environments
rev: true
}
},
main: {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/per-environment/public/maps/main-c9f76dae.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/per-environment/public/maps/main.css.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/per-environment/public/maps/threve.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions examples/per-environment/public/threeve-40307fcc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions examples/per-environment/public/threve.js

This file was deleted.

12 changes: 6 additions & 6 deletions examples/result-json/bundle.result.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"customJs": {
"scripts": "<script src='/public/customJs.js' type='text/javascript'></script>"
"scripts": "<script src='/public/customJs-33c43745.js' type='text/javascript'></script>"
},
"lessBundle": {
"styles": "<link href='/public/lessBundle.css' media='screen' rel='stylesheet' type='text/css'/>"
"styles": "<link href='/public/lessBundle-082e7061.css' media='screen' rel='stylesheet' type='text/css'/>"
},
"main": {
"styles": "<link href='/public/main.css' media='screen' rel='stylesheet' type='text/css'/>",
"scripts": "<script src='/public/main.js' type='text/javascript'></script>"
"styles": "<link href='/public/main-8e6d79da.css' media='screen' rel='stylesheet' type='text/css'/>",
"scripts": "<script src='/public/main-5f17cd21.js' type='text/javascript'></script>"
},
"vendor": {
"scripts": "<script src='/public/vendor.js' type='text/javascript'></script>",
"styles": "<link href='/public/vendor.css' media='screen' rel='stylesheet' type='text/css'/>"
"scripts": "<script src='/public/vendor-d66b96f5.js' type='text/javascript'></script>",
"styles": "<link href='/public/vendor-23d5c9c6.css' media='screen' rel='stylesheet' type='text/css'/>"
}
}
2 changes: 2 additions & 0 deletions examples/result-json/public/customJs-33c43745.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions examples/result-json/public/customJs.js

This file was deleted.

5 changes: 5 additions & 0 deletions examples/result-json/public/lessBundle-082e7061.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions examples/result-json/public/lessBundle.css

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions examples/result-json/public/main-8e6d79da.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions examples/result-json/public/main.css

This file was deleted.

1 change: 1 addition & 0 deletions examples/result-json/public/maps/customJs-33c43745.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/result-json/public/maps/customJs.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/result-json/public/maps/lessBundle.css.map

This file was deleted.

1 change: 1 addition & 0 deletions examples/result-json/public/maps/main-5f17cd21.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/result-json/public/maps/main-8e6d79da.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/result-json/public/maps/main.css.map

This file was deleted.

1 change: 0 additions & 1 deletion examples/result-json/public/maps/main.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/result-json/public/maps/vendor-d66b96f5.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/result-json/public/maps/vendor.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions examples/result-json/public/vendor-d66b96f5.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions examples/result-json/public/vendor.js

This file was deleted.

5 changes: 4 additions & 1 deletion examples/simple/bundle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ module.exports = {
],
styles: [
'./content/**/*.css'
]
],
options: {
rev: false
}
}
},
copy: './content/**/*.{png,svg}'
Expand Down
File renamed without changes.
11 changes: 7 additions & 4 deletions lib/stream-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ var fs = require('fs'),
gutil = require('gulp-util'),
gif = require('gulp-if'),
less = require('gulp-less'),
rev = require('gulp-rev'),
each = require('lodash').each,
shouldUglify = require('./should-uglify'),
isEnabled = require('./is-enabled'),
pathifySrc = require('./pathify-config-src'),
minifyCSS = require('gulp-minify-css');

Expand Down Expand Up @@ -99,19 +100,21 @@ function bundle(config) {
/* jshint -W035 */
if (type === BundleKeys.SCRIPTS) {
streams.push(gulp.src(pathifySrc(namedBundleObj[BundleKeys.SCRIPTS], config.base, namedBundleObj[BundleKeys.OPTIONS]), {base: config.base})
.pipe(using(bundleName, 'js'))
.pipe(using(bundleName, BundleKeys.SCRIPTS))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(concat(bundleName + '.js'))
.pipe(gif(shouldUglify.bind(null, namedBundleObj[BundleKeys.OPTIONS].uglify), uglify()))
.pipe(gif(isEnabled.bind(null, namedBundleObj[BundleKeys.OPTIONS].uglify), uglify()))
.pipe(gif(isEnabled.bind(null, namedBundleObj[BundleKeys.OPTIONS].rev), rev()))
.pipe(sourcemaps.write('maps'))
.pipe(applyResults(bundleName, BundleKeys.SCRIPTS)));
} else if (type === BundleKeys.STYLES) {
streams.push(gulp.src(pathifySrc(namedBundleObj[BundleKeys.STYLES], config.base, namedBundleObj[BundleKeys.OPTIONS]), {base: config.base})
.pipe(using(bundleName, 'css'))
.pipe(using(bundleName, BundleKeys.STYLES))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(gif(isLessFile, less()))
.pipe(concat(bundleName + '.css'))
//.pipe(minifyCSS()) // todo fix for source maps
.pipe(gif(isEnabled.bind(null, namedBundleObj[BundleKeys.OPTIONS].rev), rev()))
.pipe(sourcemaps.write('maps'))
.pipe(applyResults(bundleName, BundleKeys.STYLES)));
} else if (type === BundleKeys.OPTIONS) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-bundle-assets",
"version": "2.5.0",
"version": "2.6.0",
"description": "Create asset (js, css) bundles from a config file leveraging the power of streams",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -37,6 +37,7 @@
"gulp-if": "1.2.4",
"gulp-less": "1.3.2",
"gulp-minify-css": "0.3.6",
"gulp-rev": "^1.0.0",
"gulp-sourcemaps": "0.4.5",
"gulp-uglify": "0.3.1",
"gulp-using": "0.0.1",
Expand All @@ -61,4 +62,4 @@
"should": "4.0.4",
"sinon": "1.10.3"
}
}
}
15 changes: 12 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

> Create asset (js, css) bundles from a config file leveraging the power of streams
Uses the following gulp modules under the covers when creating bundles:

1. [gulp-concat](https://github.com/wearefractal/gulp-concat)
2. [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps)
3. [gulp-uglify](https://github.com/terinjokes/gulp-uglify)
4. [gulp-less](https://github.com/plus3network/gulp-less)
5. [gulp-rev](https://github.com/sindresorhus/gulp-rev)
6. [gulp-using](https://github.com/jeromedecoster/gulp-using)

## Install

```bash
Expand Down Expand Up @@ -56,9 +65,9 @@ Will result in the following folder structure:
|-- content
| |-- fonts
| |-- images
`main.css
`main.js
`vendor.js
`main-8e6d79da.css
`main-5f17cd21.js
`vendor-d66b96f5.js
```

see [the examples folder](examples) for more detail
Expand Down
Loading

0 comments on commit 434d9ba

Please sign in to comment.