diff --git a/examples/full/bundle.config.js b/examples/full/bundle.config.js
index 1871ad1e..cfffaf6c 100644
--- a/examples/full/bundle.config.js
+++ b/examples/full/bundle.config.js
@@ -130,6 +130,53 @@ module.exports = {
rev: prodLikeEnvs,
maps: false // {(boolean)} disable sourcemaps
}
+ },
+ 'ordered-bundle': {
+ scripts: [
+ {
+ src: './ordered_bundle/bower_components/jquery.js',
+ minSrc: './ordered_bundle/bower_components/jquery.min.js'
+ },
+ './ordered_bundle/vendor/*.js',
+ './ordered_bundle/content/*.coffee',
+ './ordered_bundle/content/*.js'
+ ],
+ styles: [
+ {
+ src: './ordered_bundle/bower_components/bootstrap.css',
+ minSrc: './ordered_bundle/bower_components/bootstrap.min.css'
+ },
+ './ordered_bundle/vendor/*.css',
+ './ordered_bundle/content/*.less',
+ './ordered_bundle/content/*.css'
+ ],
+ options: {
+ useMin: prodLikeEnvs,
+ order: {
+ scripts: [
+ '**/always-first.js', // from /content
+ '**/jquery*.js', // depending on env, this could be streaming min or non-min file so use trailing *
+ '**/lodash.js', // from /vendor
+ '**/file1.js', // compiled from file1.coffee
+ '**/file2.js', // compiled from file2.coffee
+ '!**/always-last.js', // everything else except always-last.js
+ '**/always-last.js' // from /content
+ ],
+ styles: [
+ '**/always-first.css', // from /content
+ '**/bootstrap*.css', // depending on env, this could be streaming min or non-min file so use trailing *
+ '**/vendor.css', // from /vendor
+ '**/file1.css', // compiled from file1.less
+ '**/file2.css', // compiled from file2.less
+ '!**/always-last.css', // everything else except always-last.css
+ '**/always-last.css' // from /content
+ ]
+ },
+ transforms: {
+ scripts: transformHelper.coffee(),
+ styles: transformHelper.less()
+ }
+ }
}
},
copy: [
diff --git a/examples/full/manifest.json b/examples/full/manifest.json
index 3e9601cc..404c8ffc 100644
--- a/examples/full/manifest.json
+++ b/examples/full/manifest.json
@@ -17,5 +17,9 @@
"main": {
"scripts": "",
"styles": ""
+ },
+ "ordered-bundle": {
+ "styles": "",
+ "scripts": ""
}
}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/bower_components/bootstrap.css b/examples/full/ordered_bundle/bower_components/bootstrap.css
new file mode 100644
index 00000000..bedf20eb
--- /dev/null
+++ b/examples/full/ordered_bundle/bower_components/bootstrap.css
@@ -0,0 +1,3 @@
+.bootstrap {
+ background-color: orange;
+}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/bower_components/bootstrap.min.css b/examples/full/ordered_bundle/bower_components/bootstrap.min.css
new file mode 100644
index 00000000..ab826734
--- /dev/null
+++ b/examples/full/ordered_bundle/bower_components/bootstrap.min.css
@@ -0,0 +1 @@
+.bootstrap-min {background-color: coral;}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/bower_components/jquery.js b/examples/full/ordered_bundle/bower_components/jquery.js
new file mode 100644
index 00000000..690d2a17
--- /dev/null
+++ b/examples/full/ordered_bundle/bower_components/jquery.js
@@ -0,0 +1 @@
+console.log("jquery");
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/bower_components/jquery.min.js b/examples/full/ordered_bundle/bower_components/jquery.min.js
new file mode 100644
index 00000000..0443159d
--- /dev/null
+++ b/examples/full/ordered_bundle/bower_components/jquery.min.js
@@ -0,0 +1 @@
+console.log("jquery.min");
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/always-first.css b/examples/full/ordered_bundle/content/always-first.css
new file mode 100644
index 00000000..2363bfef
--- /dev/null
+++ b/examples/full/ordered_bundle/content/always-first.css
@@ -0,0 +1,3 @@
+.always-first {
+ background-color: red;
+}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/always-first.js b/examples/full/ordered_bundle/content/always-first.js
new file mode 100644
index 00000000..80a6d7dc
--- /dev/null
+++ b/examples/full/ordered_bundle/content/always-first.js
@@ -0,0 +1 @@
+console.log("first");
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/always-last.css b/examples/full/ordered_bundle/content/always-last.css
new file mode 100644
index 00000000..f4ec92b8
--- /dev/null
+++ b/examples/full/ordered_bundle/content/always-last.css
@@ -0,0 +1,3 @@
+.always-last {
+ background-color: green;
+}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/always-last.js b/examples/full/ordered_bundle/content/always-last.js
new file mode 100644
index 00000000..f679b3ca
--- /dev/null
+++ b/examples/full/ordered_bundle/content/always-last.js
@@ -0,0 +1 @@
+console.log("last");
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/file1.coffee b/examples/full/ordered_bundle/content/file1.coffee
new file mode 100644
index 00000000..af8fab6c
--- /dev/null
+++ b/examples/full/ordered_bundle/content/file1.coffee
@@ -0,0 +1 @@
+fileName = 'file1.coffee'
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/file1.less b/examples/full/ordered_bundle/content/file1.less
new file mode 100644
index 00000000..3af6cfee
--- /dev/null
+++ b/examples/full/ordered_bundle/content/file1.less
@@ -0,0 +1,3 @@
+.file1-less {
+ background-color: purple;
+}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/file2.coffee b/examples/full/ordered_bundle/content/file2.coffee
new file mode 100644
index 00000000..55fbc814
--- /dev/null
+++ b/examples/full/ordered_bundle/content/file2.coffee
@@ -0,0 +1 @@
+fileName = 'file2.coffee'
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/file2.less b/examples/full/ordered_bundle/content/file2.less
new file mode 100644
index 00000000..7236549c
--- /dev/null
+++ b/examples/full/ordered_bundle/content/file2.less
@@ -0,0 +1,3 @@
+.file2-less {
+ background-color: yellow;
+}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/for-the-middle.css b/examples/full/ordered_bundle/content/for-the-middle.css
new file mode 100644
index 00000000..293cdc09
--- /dev/null
+++ b/examples/full/ordered_bundle/content/for-the-middle.css
@@ -0,0 +1,3 @@
+.something-in-the-middle {
+ background-color: blue;
+}
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/content/for-the-middle.js b/examples/full/ordered_bundle/content/for-the-middle.js
new file mode 100644
index 00000000..948443c7
--- /dev/null
+++ b/examples/full/ordered_bundle/content/for-the-middle.js
@@ -0,0 +1 @@
+console.log("something in the middle");
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/vendor/lodash.js b/examples/full/ordered_bundle/vendor/lodash.js
new file mode 100644
index 00000000..1fdd5155
--- /dev/null
+++ b/examples/full/ordered_bundle/vendor/lodash.js
@@ -0,0 +1 @@
+console.log("lodash");
\ No newline at end of file
diff --git a/examples/full/ordered_bundle/vendor/vendor.css b/examples/full/ordered_bundle/vendor/vendor.css
new file mode 100644
index 00000000..a1278492
--- /dev/null
+++ b/examples/full/ordered_bundle/vendor/vendor.css
@@ -0,0 +1,3 @@
+.vendor {
+ background-color: wheat;
+}
\ No newline at end of file
diff --git a/examples/full/public/maps/ordered-bundle-421fc9b36f.css.map b/examples/full/public/maps/ordered-bundle-421fc9b36f.css.map
new file mode 100644
index 00000000..fc114acf
--- /dev/null
+++ b/examples/full/public/maps/ordered-bundle-421fc9b36f.css.map
@@ -0,0 +1 @@
+{"version":3,"sources":["ordered_bundle/content/always-first.css","ordered_bundle/vendor/vendor.css","ordered_bundle/content/file1.less","ordered_bundle/content/file2.less","ordered_bundle/bower_components/bootstrap.min.css","ordered_bundle/content/for-the-middle.css","ordered_bundle/content/always-last.css"],"names":[],"mappings":"AAAA,cACE,iBAAkB;ACDpB,QACE,iBAAkB;ACDpB,YACE,iBAAA;ACDF,YACE,iBAAA;ACDF;ACAA,yBACE,iBAAkB;ACDpB,aACE,iBAAkB","file":"ordered-bundle-421fc9b36f.css","sourcesContent":[".always-first {\n background-color: red;\n}",".vendor {\n background-color: wheat;\n}",".file1-less {\n background-color: purple;\n}",".file2-less {\n background-color: yellow;\n}",".bootstrap-min {background-color: coral;}",".something-in-the-middle {\n background-color: blue;\n}",".always-last {\n background-color: green;\n}"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/examples/full/public/maps/ordered-bundle-cbd3c3edb4.js.map b/examples/full/public/maps/ordered-bundle-cbd3c3edb4.js.map
new file mode 100644
index 00000000..f3901d10
--- /dev/null
+++ b/examples/full/public/maps/ordered-bundle-cbd3c3edb4.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["ordered_bundle/content/always-first.js","ordered_bundle/bower_components/jquery.min.js","ordered_bundle/vendor/lodash.js","ordered_bundle/content/file1.coffee","ordered_bundle/content/file1.js","ordered_bundle/content/file2.coffee","ordered_bundle/content/file2.js","ordered_bundle/content/for-the-middle.js","ordered_bundle/content/always-last.js"],"names":["console","log","fileName","call","this"],"mappings":"AAAAA,QAAQC,IAAI;ACAZ;ACAAD,QAAQC,IAAI;CCAZ,WAAA,GAAAC,EAAAA,GAAW,iBCKRC,KAAKC;CCLR,WAAA,GAAAF,EAAAA,GAAW,iBCKRC,KAAKC;ACLRJ,QAAQC,IAAI;ACAZD,QAAQC,IAAI","file":"ordered-bundle-cbd3c3edb4.js","sourcesContent":["console.log(\"first\");","console.log(\"jquery.min\");","console.log(\"lodash\");","fileName = 'file1.coffee'",null,"fileName = 'file2.coffee'",null,"console.log(\"something in the middle\");","console.log(\"last\");"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/examples/full/public/ordered-bundle-421fc9b36f.css b/examples/full/public/ordered-bundle-421fc9b36f.css
new file mode 100644
index 00000000..9856bb2b
--- /dev/null
+++ b/examples/full/public/ordered-bundle-421fc9b36f.css
@@ -0,0 +1,8 @@
+.always-first{background-color:red}
+.vendor{background-color:wheat}
+.file1-less{background-color:purple}
+.file2-less{background-color:#ff0}
+.bootstrap-min {background-color: coral;}
+.something-in-the-middle{background-color:#00f}
+.always-last{background-color:green}
+/*# sourceMappingURL=maps/ordered-bundle-421fc9b36f.css.map */
\ No newline at end of file
diff --git a/examples/full/public/ordered-bundle-cbd3c3edb4.js b/examples/full/public/ordered-bundle-cbd3c3edb4.js
new file mode 100644
index 00000000..e3f5e309
--- /dev/null
+++ b/examples/full/public/ordered-bundle-cbd3c3edb4.js
@@ -0,0 +1,8 @@
+console.log("first");
+console.log("jquery.min");
+console.log("lodash");
+(function(){var f;f="file1.coffee"}).call(this);
+(function(){var f;f="file2.coffee"}).call(this);
+console.log("something in the middle");
+console.log("last");
+//# sourceMappingURL=maps/ordered-bundle-cbd3c3edb4.js.map
\ No newline at end of file
diff --git a/examples/guarantee-content-order/README.md b/examples/guarantee-content-order/README.md
new file mode 100644
index 00000000..b6b49bb6
--- /dev/null
+++ b/examples/guarantee-content-order/README.md
@@ -0,0 +1,44 @@
+# Guarantee Bundle Content Order
+
+The bundle config supports ordering the src files via `gulp-order` syntax (e.g. wildcards, etc). See here for details on syntax: https://github.com/sirlantis/gulp-order
+
+To use simply add your ordering array to the `order` option:
+
+```js
+module.exports = {
+ bundle: {
+ main: {
+ scripts: [
+ {
+ src: './vendor/second.js',
+ minSrc: './vendor/second.min.js'
+ },
+ './a/*.coffee',
+ './content/**/*.coffee',
+ './content/**/*.js'
+ ]
+ options: {
+ order: {
+ scripts: [
+ '**/always-first.js', // from /content
+ '**/second*.js', // depending on env, this could be streaming min or non-min file so use trailing *
+ '**/third.js', // compiled from third.coffee
+ '**/fourth.js', // compiled from fourth.coffee
+ '!**/always-last.js', // everything else except always-last.js
+ '**/always-last.js' // from /content
+ ]
+ },
+ transforms: {
+ scripts: transformHelper.coffee()
+ }
+ }
+ }
+ }
+};
+
+```
+
+### Examples
+
+* This example [`bundle.config.js`](bundle.config.js#L25)
+* full example [`bundle.config.js`](../full/bundle.config.js#L155)
diff --git a/examples/guarantee-content-order/a/fourth.coffee b/examples/guarantee-content-order/a/fourth.coffee
new file mode 100644
index 00000000..31ddd456
--- /dev/null
+++ b/examples/guarantee-content-order/a/fourth.coffee
@@ -0,0 +1 @@
+fileName = 'fourth'
\ No newline at end of file
diff --git a/examples/guarantee-content-order/a/fourth.less b/examples/guarantee-content-order/a/fourth.less
new file mode 100644
index 00000000..ac838196
--- /dev/null
+++ b/examples/guarantee-content-order/a/fourth.less
@@ -0,0 +1,3 @@
+.fourth {
+ background-color: purple;
+}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/bundle.config.js b/examples/guarantee-content-order/bundle.config.js
new file mode 100644
index 00000000..52ebf2c7
--- /dev/null
+++ b/examples/guarantee-content-order/bundle.config.js
@@ -0,0 +1,51 @@
+var transformHelper = require('../../index.js').transformHelper;
+
+module.exports = {
+ bundle: {
+ 'ordered-bundle': {
+ scripts: [
+ {
+ src: './vendor/second.js',
+ minSrc: './vendor/second.min.js'
+ },
+ './a/*.coffee',
+ './content/**/*.coffee',
+ './content/**/*.js'
+ ],
+ styles: [
+ {
+ src: './vendor/second.css',
+ minSrc: './vendor/second.min.css'
+ },
+ './a/*.less',
+ './content/**/*.less',
+ './content/**/*.css'
+ ],
+ options: {
+ order: {
+ scripts: [
+ '**/always-first.js', // from /content
+ '**/second*.js', // depending on env, this could be streaming min or non-min file so use trailing *
+ '**/third.js', // compiled from third.coffee
+ '**/fourth.js', // compiled from fourth.coffee
+ '!**/always-last.js', // everything else except always-last.js
+ '**/always-last.js' // from /content
+ ],
+ styles: [
+ '**/always-first.css', // from /content
+ '**/second*.css', // depending on env, this could be streaming min or non-min file so use trailing *
+ '**/third.css', // compiled from third.less
+ '**/fourth.css', // compiled from fourth.less
+ '!**/always-last.css', // everything else except always-last.css
+ '**/always-last.css' // from /content
+ ]
+ },
+ useMin: 'production',
+ transforms: {
+ scripts: transformHelper.coffee(),
+ styles: transformHelper.less()
+ }
+ }
+ }
+ }
+};
diff --git a/examples/guarantee-content-order/content/always-last.css b/examples/guarantee-content-order/content/always-last.css
new file mode 100644
index 00000000..f4ec92b8
--- /dev/null
+++ b/examples/guarantee-content-order/content/always-last.css
@@ -0,0 +1,3 @@
+.always-last {
+ background-color: green;
+}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/always-last.js b/examples/guarantee-content-order/content/always-last.js
new file mode 100644
index 00000000..bbf927ad
--- /dev/null
+++ b/examples/guarantee-content-order/content/always-last.js
@@ -0,0 +1 @@
+console.log('last');
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/fifth.css b/examples/guarantee-content-order/content/fifth.css
new file mode 100644
index 00000000..66dce712
--- /dev/null
+++ b/examples/guarantee-content-order/content/fifth.css
@@ -0,0 +1,3 @@
+.fifth {
+ background-color: blue;
+}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/fifth.js b/examples/guarantee-content-order/content/fifth.js
new file mode 100644
index 00000000..a5844657
--- /dev/null
+++ b/examples/guarantee-content-order/content/fifth.js
@@ -0,0 +1 @@
+console.log('fifth');
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/sub/folder/always-first.css b/examples/guarantee-content-order/content/sub/folder/always-first.css
new file mode 100644
index 00000000..2363bfef
--- /dev/null
+++ b/examples/guarantee-content-order/content/sub/folder/always-first.css
@@ -0,0 +1,3 @@
+.always-first {
+ background-color: red;
+}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/sub/folder/always-first.js b/examples/guarantee-content-order/content/sub/folder/always-first.js
new file mode 100644
index 00000000..17e3d090
--- /dev/null
+++ b/examples/guarantee-content-order/content/sub/folder/always-first.js
@@ -0,0 +1 @@
+console.log('first');
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/third.coffee b/examples/guarantee-content-order/content/third.coffee
new file mode 100644
index 00000000..80d5c131
--- /dev/null
+++ b/examples/guarantee-content-order/content/third.coffee
@@ -0,0 +1 @@
+fileName = 'third'
\ No newline at end of file
diff --git a/examples/guarantee-content-order/content/third.less b/examples/guarantee-content-order/content/third.less
new file mode 100644
index 00000000..d955e647
--- /dev/null
+++ b/examples/guarantee-content-order/content/third.less
@@ -0,0 +1,3 @@
+.third {
+ background-color: yellow;
+}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/dist/maps/ordered-bundle-9b08eb592f.js.map b/examples/guarantee-content-order/dist/maps/ordered-bundle-9b08eb592f.js.map
new file mode 100644
index 00000000..5ad6bbdc
--- /dev/null
+++ b/examples/guarantee-content-order/dist/maps/ordered-bundle-9b08eb592f.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["content/sub/folder/always-first.js","vendor/second.js","content/third.coffee","content/third.js","a/fourth.coffee","a/fourth.js","content/fifth.js","content/always-last.js"],"names":["console","log","fileName","call","this"],"mappings":"AAAAA,QAAQC,IAAI;ACAZ;CCAA,WAAA,GAAAC,EAAAA,GAAW,UCKRC,KAAKC;CCLR,WAAA,GAAAF,EAAAA,GAAW,WCKRC,KAAKC;ACLRJ,QAAQC,IAAI;ACAZD,QAAQC,IAAI","file":"ordered-bundle-9b08eb592f.js","sourcesContent":["console.log('first');","console.log('second');","fileName = 'third'",null,"fileName = 'fourth'",null,"console.log('fifth');","console.log('last');"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/dist/maps/ordered-bundle-c81d39b7f1.css.map b/examples/guarantee-content-order/dist/maps/ordered-bundle-c81d39b7f1.css.map
new file mode 100644
index 00000000..ead22dbf
--- /dev/null
+++ b/examples/guarantee-content-order/dist/maps/ordered-bundle-c81d39b7f1.css.map
@@ -0,0 +1 @@
+{"version":3,"sources":["content/sub/folder/always-first.css","vendor/second.css","content/third.less","a/fourth.less","content/fifth.css","content/always-last.css"],"names":[],"mappings":"AAAA,cACE,iBAAkB;ACDpB;AACA;AACA;ACFA,OACE,iBAAA;ACDF,QACE,iBAAA;ACDF,OACE,iBAAkB;ACDpB,aACE,iBAAkB","file":"ordered-bundle-c81d39b7f1.css","sourcesContent":[".always-first {\n background-color: red;\n}",".second {\n background-color: orange;\n}",".third {\n background-color: yellow;\n}",".fourth {\n background-color: purple;\n}",".fifth {\n background-color: blue;\n}",".always-last {\n background-color: green;\n}"],"sourceRoot":"/source/"}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/dist/ordered-bundle-9b08eb592f.js b/examples/guarantee-content-order/dist/ordered-bundle-9b08eb592f.js
new file mode 100644
index 00000000..02d7348f
--- /dev/null
+++ b/examples/guarantee-content-order/dist/ordered-bundle-9b08eb592f.js
@@ -0,0 +1,7 @@
+console.log("first");
+console.log('second');
+(function(){var i;i="third"}).call(this);
+(function(){var t;t="fourth"}).call(this);
+console.log("fifth");
+console.log("last");
+//# sourceMappingURL=maps/ordered-bundle-9b08eb592f.js.map
\ No newline at end of file
diff --git a/examples/guarantee-content-order/dist/ordered-bundle-c81d39b7f1.css b/examples/guarantee-content-order/dist/ordered-bundle-c81d39b7f1.css
new file mode 100644
index 00000000..5cb19cb0
--- /dev/null
+++ b/examples/guarantee-content-order/dist/ordered-bundle-c81d39b7f1.css
@@ -0,0 +1,9 @@
+.always-first{background-color:red}
+.second {
+ background-color: orange;
+}
+.third{background-color:#ff0}
+.fourth{background-color:purple}
+.fifth{background-color:#00f}
+.always-last{background-color:green}
+/*# sourceMappingURL=maps/ordered-bundle-c81d39b7f1.css.map */
\ No newline at end of file
diff --git a/examples/guarantee-content-order/gulpfile.js b/examples/guarantee-content-order/gulpfile.js
new file mode 100644
index 00000000..0a3356a8
--- /dev/null
+++ b/examples/guarantee-content-order/gulpfile.js
@@ -0,0 +1,17 @@
+var gulp = require('gulp'),
+ del = require('del'),
+ bundle = require('../../index');
+
+gulp.task('bundle', ['clean'], function () {
+ return gulp.src('./bundle.config.js')
+ .pipe(bundle())
+ .pipe(gulp.dest('./dist'));
+});
+
+gulp.task('clean', function (cb) {
+ del([
+ './dist'
+ ], cb);
+});
+
+gulp.task('default', ['bundle']);
\ No newline at end of file
diff --git a/examples/guarantee-content-order/package.json b/examples/guarantee-content-order/package.json
new file mode 100644
index 00000000..d753a586
--- /dev/null
+++ b/examples/guarantee-content-order/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "guarantee-content-order",
+ "version": "1.0.0",
+ "description": "",
+ "main": "bundle.config.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "",
+ "license": "MIT",
+ "dependencies": {
+ "del": "^1.2.0",
+ "gulp": "^3.9.0"
+ }
+}
diff --git a/examples/guarantee-content-order/vendor/second.css b/examples/guarantee-content-order/vendor/second.css
new file mode 100644
index 00000000..b6c6a375
--- /dev/null
+++ b/examples/guarantee-content-order/vendor/second.css
@@ -0,0 +1,3 @@
+.second {
+ background-color: orange;
+}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/vendor/second.js b/examples/guarantee-content-order/vendor/second.js
new file mode 100644
index 00000000..05ca0844
--- /dev/null
+++ b/examples/guarantee-content-order/vendor/second.js
@@ -0,0 +1 @@
+console.log('second');
\ No newline at end of file
diff --git a/examples/guarantee-content-order/vendor/second.min.css b/examples/guarantee-content-order/vendor/second.min.css
new file mode 100644
index 00000000..84f204e7
--- /dev/null
+++ b/examples/guarantee-content-order/vendor/second.min.css
@@ -0,0 +1 @@
+.second-min {background-color: coral;}
\ No newline at end of file
diff --git a/examples/guarantee-content-order/vendor/second.min.js b/examples/guarantee-content-order/vendor/second.min.js
new file mode 100644
index 00000000..8f51dc71
--- /dev/null
+++ b/examples/guarantee-content-order/vendor/second.min.js
@@ -0,0 +1 @@
+console.log('second.min');
\ No newline at end of file
diff --git a/lib/init-option-defaults.js b/lib/init-option-defaults.js
index b6dd580b..e1f2759e 100644
--- a/lib/init-option-defaults.js
+++ b/lib/init-option-defaults.js
@@ -11,4 +11,5 @@ module.exports = function (bundle) {
bundle[BundleKeys.OPTIONS].pluginOptions['gulp-minify-css'] = bundle[BundleKeys.OPTIONS].pluginOptions['gulp-minify-css'] || {};
bundle[BundleKeys.OPTIONS].pluginOptions['gulp-uglify'] = bundle[BundleKeys.OPTIONS].pluginOptions['gulp-uglify'] || {};
bundle[BundleKeys.OPTIONS].pluginOptions['gulp-concat'] = bundle[BundleKeys.OPTIONS].pluginOptions['gulp-concat'] || {};
+ bundle[BundleKeys.OPTIONS].order = bundle[BundleKeys.OPTIONS].order || {};
};
\ No newline at end of file
diff --git a/lib/stream-files.js b/lib/stream-files.js
index 5d2f3f28..be99a17c 100644
--- a/lib/stream-files.js
+++ b/lib/stream-files.js
@@ -8,6 +8,7 @@ var gulp = require('gulp'),
minifyCSS = require('gulp-minify-css'),
gsourcemaps = require('gulp-sourcemaps'),
gutil = require('gulp-util'),
+ order = require('gulp-order'),
logger = require('./service/logger'),
using = require('./using'),
sourcemaps = require('./sourcemaps'),
@@ -76,6 +77,10 @@ module.exports.scripts = function (opts) {
.on('error', function (e) {
self.handleTransformError(this, opts.isWatch, opts.bundleName, BundleKeys.SCRIPTS, e);
})
+ .pipe(gif(function (file) {
+ return opts.bundleOptions.order && opts.bundleOptions.order.scripts;
+ }, order(opts.bundleOptions.order.scripts)
+ ))
.pipe(gif(function (file) {
return file.isStream();
},
@@ -119,6 +124,10 @@ module.exports.styles = function (opts) {
.pipe(gif(function (file) {
return isMinEnabled.css(file, opts);
}, minifyCSS(opts.bundleOptions.pluginOptions['gulp-minify-css'])))
+ .pipe(gif(function (file) {
+ return opts.bundleOptions.order && opts.bundleOptions.order.styles;
+ }, order(opts.bundleOptions.order.styles)
+ ))
.pipe(concat(opts.bundleName + ((opts.isBundleAll && opts.env) ? '.' + opts.env : '') + '.css'))
.pipe(gif(isOptionEnabled(opts.bundleOptions.rev, opts.env), rev()))
.pipe(gif(function (file) {
diff --git a/package.json b/package.json
index 82e402d3..72e07b55 100644
--- a/package.json
+++ b/package.json
@@ -69,6 +69,7 @@
"gulp-if": "1.2.5",
"gulp-less": "3.0.3",
"gulp-minify-css": "1.1.6",
+ "gulp-order": "1.1.1",
"gulp-rev": "4.0.0",
"gulp-sourcemaps": "1.5.2",
"gulp-streamify": "0.0.5",
@@ -79,7 +80,7 @@
"map-stream": "0.0.5",
"merge-stream": "0.1.7",
"mkdirp": "0.5.1",
- "pretty-hrtime": "^1.0.0",
+ "pretty-hrtime": "1.0.0",
"readable-stream": "2.0.0",
"through2": "2.0.0",
"vinyl": "0.5.0"
diff --git a/readme.md b/readme.md
index 4f54617f..fbdd5471 100644
--- a/readme.md
+++ b/readme.md
@@ -9,6 +9,7 @@ By default uses the following gulp modules under the covers when creating bundle
3. [gulp-uglify](https://github.com/terinjokes/gulp-uglify)
4. [gulp-minify-css](https://github.com/jonathanepollack/gulp-minify-css)
6. [gulp-rev](https://github.com/sindresorhus/gulp-rev)
+7. [gulp-order](https://github.com/sirlantis/gulp-order)
This project's stream architecture also allows you to plugin [any gulp transform you wish](examples/custom-transforms).
@@ -129,6 +130,7 @@ Which results in a `bundle.result.json` file similar to:
* e.g. create a bundle.result.json for html, jsx or any custom results you can think of
6. [works alongside 3rd party transformers](examples/browserify)
* e.g. create a bundle using [browserify](http://browserify.org/), [6to5](https://github.com/sebmck/6to5), etc.
+7. [guarantee bundle content order](examples/guarantee-content-order)
## Why?
diff --git a/test/integ/index-test.js b/test/integ/index-test.js
index ac4c710b..f7a4c748 100644
--- a/test/integ/index-test.js
+++ b/test/integ/index-test.js
@@ -380,7 +380,9 @@ describe('integration tests', function () {
MAIN_CONTENT_NOT_UGLIFIED = 'console.log(\"app\")\nconsole.log(\"controllers\")\nconsole.log(\"directives\")\nconsole.log(\"filters\")\n',
MAIN_CONTENT_UGLIFIED = 'console.log(\"app\");\nconsole.log(\"controllers\");\nconsole.log(\"directives\");\nconsole.log(\"filters\");\n',
MAIN_CSS_CONTENT_MINIFIED = '.legacy{background-color:green}\nbody{background-color:#00f}\n',
- MAIN_CSS_CONTENT_NOT_MINIFIED = '.legacy {\n background-color: green;\n}\nbody {\n background-color: blue;\n}\n\n';
+ MAIN_CSS_CONTENT_NOT_MINIFIED = '.legacy {\n background-color: green;\n}\nbody {\n background-color: blue;\n}\n\n',
+ ORDERED_BUNDLE_CONTENT = 'console.log("first");\nconsole.log("jquery.min");\nconsole.log("lodash");\n(function(){var f;f="file1.coffee"}).call(this);\n(function(){var f;f="file2.coffee"}).call(this);\nconsole.log("something in the middle");\nconsole.log("last");\n',
+ ORDERED_BUNDLE_CSS_CONTENT = '.always-first{background-color:red}\n.bootstrap-min {background-color: coral;}\n.vendor{background-color:wheat}\n.file1-less{background-color:purple}\n.file2-less{background-color:#ff0}\n.something-in-the-middle{background-color:#00f}\n.always-last{background-color:green}\n';
it('should read bundle.config and create bundles in prod mode', function (done) {
@@ -424,6 +426,14 @@ describe('integration tests', function () {
helpers.getJsSrcMapLine(file.relative));
} else if (file.relative === 'jquery-stand-alone-29f6b03537.js') {
fileContents.should.eql(JQUERY_CONTENT_MIN_NOT_UGLIFIED_NO_MAPS); // no sourcemaps
+ } else if (file.relative === 'ordered-bundle-cbd3c3edb4.js') {
+ fileContents.should.eql(
+ ORDERED_BUNDLE_CONTENT +
+ helpers.getJsSrcMapLine(file.relative));
+ } else if (file.relative === 'ordered-bundle-d8d01cbb86.css') {
+ fileContents.should.eql(
+ ORDERED_BUNDLE_CSS_CONTENT +
+ helpers.getCssSrcMapLine(file.relative));
} else if (helpers.stringEndsWith(file.relative, '.map') ||
file.relative === 'fonts/glyphicons-halflings-regular.eot' ||
file.relative === 'fonts/glyphicons-halflings-regular.svg' ||
@@ -438,8 +448,8 @@ describe('integration tests', function () {
}
fileCount++;
}, function () {
- (fileCount).should.eql(24);
- (staticFileCount).should.eql(15);
+ (fileCount).should.eql(28);
+ (staticFileCount).should.eql(17);
});
});
diff --git a/test/unit/stream-files-test.js b/test/unit/stream-files-test.js
index b795a351..426e7cea 100644
--- a/test/unit/stream-files-test.js
+++ b/test/unit/stream-files-test.js
@@ -39,7 +39,8 @@ describe('stream-files', function () {
'gulp-minify-css': {},
'gulp-uglify': {},
'gulp-concat': {}
- }
+ },
+ order: {}
}
};
streamFiles.styles(opts);
@@ -74,7 +75,8 @@ describe('stream-files', function () {
'gulp-minify-css': {},
'gulp-uglify': {},
'gulp-concat': {}
- }
+ },
+ order: {}
}
};
streamFiles.scripts(opts);