1
1
var addSrc = require ( 'gulp-add-src' ) ;
2
- var babel = require ( 'gulp-babel' ) ;
3
- var concat = require ( 'gulp-concat' ) ;
4
2
var cleancss = require ( 'gulp-clean-css' ) ;
5
3
var customizer = require ( '../../customizer/lib' ) ;
6
4
var Vinyl = require ( 'vinyl' ) ;
7
5
var fs = require ( 'fs' ) ;
8
6
var gulp = require ( 'gulp' ) ;
9
- var sequence = require ( 'run-sequence' ) ;
10
7
var If = require ( 'gulp-if' ) ;
11
8
var path = require ( 'path' ) ;
12
9
var Readable = require ( 'stream' ) . Readable ;
@@ -23,7 +20,6 @@ var postcss = require('gulp-postcss');
23
20
var autoprefixer = require ( 'autoprefixer' ) ;
24
21
var webpackStream = require ( 'webpack-stream' ) ;
25
22
var webpack = require ( 'webpack' ) ;
26
- var named = require ( 'vinyl-named' ) ;
27
23
28
24
var utils = require ( '../utils.js' ) ;
29
25
@@ -84,38 +80,35 @@ gulp.task('customizer:prepareSassDeps', function() {
84
80
} ) ;
85
81
86
82
// Creates a Sass file from the module/variable list and creates foundation.css and foundation.min.css
87
- gulp . task ( 'customizer:sass' , function ( done ) {
88
- sequence ( 'customizer:loadConfig' , 'customizer:prepareSassDeps' , function ( ) {
89
- var sassFile = customizer . sass ( CUSTOMIZER_CONFIG , MODULE_LIST , VARIABLE_LIST ) ;
90
- var stream = createStream ( 'foundation.scss' , sassFile ) ;
91
-
92
- return stream
93
- . pipe ( sass ( {
94
- includePaths : [
95
- 'scss' ,
96
- 'node_modules/motion-ui/src'
97
- ]
98
- } ) )
99
- . pipe ( postcss ( [ autoprefixer ( ) ] ) ) // uses ".browserslistrc"
100
- . pipe ( gulp . dest ( path . join ( OUTPUT_DIR , 'css' ) ) )
101
- . pipe ( cleancss ( { compatibility : 'ie9' } ) )
102
- . pipe ( rename ( 'foundation.min.css' ) )
103
- . pipe ( gulp . dest ( path . join ( OUTPUT_DIR , 'css' ) ) )
104
- . on ( 'finish' , done ) ;
105
- } ) ;
106
- } ) ;
83
+ gulp . task ( 'customizer:sass' , gulp . series ( 'customizer:loadConfig' , 'customizer:prepareSassDeps' , function ( ) {
84
+ var sassFile = customizer . sass ( CUSTOMIZER_CONFIG , MODULE_LIST , VARIABLE_LIST ) ;
85
+ var stream = createStream ( 'foundation.scss' , sassFile ) ;
86
+
87
+ return stream
88
+ . pipe ( sass ( {
89
+ includePaths : [
90
+ 'scss' ,
91
+ 'node_modules/motion-ui/src'
92
+ ]
93
+ } ) )
94
+ . pipe ( postcss ( [ autoprefixer ( ) ] ) ) // uses ".browserslistrc"
95
+ . pipe ( gulp . dest ( path . join ( OUTPUT_DIR , 'css' ) ) )
96
+ . pipe ( cleancss ( { compatibility : 'ie9' } ) )
97
+ . pipe ( rename ( 'foundation.min.css' ) )
98
+ . pipe ( gulp . dest ( path . join ( OUTPUT_DIR , 'css' ) ) )
99
+ } ) ) ;
107
100
108
101
// Creates a Foundation JavaScript file from the module list, and also copies dependencies (jQuery, what-input)
109
- gulp . task ( 'customizer:javascript-entry' , [ 'customizer:loadConfig' ] , function ( ) {
102
+ gulp . task ( 'customizer:javascript-entry' , gulp . series ( 'customizer:loadConfig' , function ( ) {
110
103
var entryFile = customizer . js ( CUSTOMIZER_CONFIG , MODULE_LIST ) ;
111
104
// Create a stream with our entry file
112
105
var stream = createStream ( 'foundation.js' , entryFile ) ;
113
106
114
107
return stream
115
108
. pipe ( gulp . dest ( path . join ( OUTPUT_DIR , 'js/vendor' ) ) ) ;
116
- } ) ;
109
+ } ) ) ;
117
110
118
- gulp . task ( 'customizer:javascript' , [ 'customizer:javascript-entry' ] , function ( ) {
111
+ gulp . task ( 'customizer:javascript' , gulp . series ( 'customizer:javascript-entry' , function ( ) {
119
112
return gulp . src ( path . join ( OUTPUT_DIR , 'js/vendor/foundation.js' ) )
120
113
. pipe ( webpackStream ( WEBPACK_CONFIG , webpack ) )
121
114
. pipe ( rename ( 'foundation.js' ) )
@@ -127,40 +120,38 @@ gulp.task('customizer:javascript', ['customizer:javascript-entry'], function() {
127
120
'node_modules/what-input/dist/what-input.js'
128
121
] ) )
129
122
. pipe ( gulp . dest ( path . join ( OUTPUT_DIR , 'js/vendor' ) ) ) ;
130
- } ) ;
123
+ } ) ) ;
131
124
132
125
// Copies the boilerplate index.html to the custom download folder
133
- gulp . task ( 'customizer:html' , [ 'customizer:loadConfig' ] , function ( ) {
126
+ gulp . task ( 'customizer:html' , gulp . series ( 'customizer:loadConfig' , function ( ) {
134
127
var rtlEnabled = VARIABLE_LIST [ 'global-text-direction' ] && VARIABLE_LIST [ 'global-text-direction' ] === 'rtl' ;
135
128
136
129
return gulp . src ( 'customizer/index.html' )
137
130
. pipe ( If ( rtlEnabled , replace ( 'ltr' , 'rtl' ) ) )
138
131
. pipe ( gulp . dest ( OUTPUT_DIR ) ) ;
139
- } ) ;
132
+ } ) ) ;
140
133
141
134
// Creates a custom build by:
142
135
// - Generating a CSS file
143
136
// - Generating a JS file
144
137
// - Copying the index.html file
145
138
// - Creating a blank app.css file
146
139
// - Creating an app.js file with Foundation initialization code
147
- gulp . task ( 'customizer' , function ( done ) {
148
- sequence ( 'customizer:sass' , 'customizer:javascript' , 'customizer:html' , function ( ) {
149
- var outputFolder = path . dirname ( OUTPUT_DIR ) ;
150
- var outputFileName = path . basename ( OUTPUT_DIR ) ;
151
-
152
- touch ( path . join ( OUTPUT_DIR , 'css/app.css' ) ) ;
153
- touch ( path . join ( OUTPUT_DIR , 'js/app.js' ) ) ;
154
- fs . writeFileSync ( path . join ( OUTPUT_DIR , 'js/app.js' ) , '$(document).foundation()\n' ) ;
155
-
156
- gulp . src ( path . join ( OUTPUT_DIR , '/**/*' ) )
157
- . pipe ( zip ( path . basename ( outputFileName ) + '.zip' ) )
158
- . pipe ( gulp . dest ( outputFolder ) )
159
- . on ( 'finish' , function ( ) {
160
- rimraf ( OUTPUT_DIR , done ) ;
161
- } ) ;
162
- } ) ;
163
- } ) ;
140
+ gulp . task ( 'customizer' , gulp . series ( 'customizer:sass' , 'customizer:javascript' , 'customizer:html' , function ( done ) {
141
+ var outputFolder = path . dirname ( OUTPUT_DIR ) ;
142
+ var outputFileName = path . basename ( OUTPUT_DIR ) ;
143
+
144
+ touch ( path . join ( OUTPUT_DIR , 'css/app.css' ) ) ;
145
+ touch ( path . join ( OUTPUT_DIR , 'js/app.js' ) ) ;
146
+ fs . writeFileSync ( path . join ( OUTPUT_DIR , 'js/app.js' ) , '$(document).foundation()\n' ) ;
147
+
148
+ gulp . src ( path . join ( OUTPUT_DIR , '/**/*' ) )
149
+ . pipe ( zip ( path . basename ( outputFileName ) + '.zip' ) )
150
+ . pipe ( gulp . dest ( outputFolder ) )
151
+ . on ( 'finish' , function ( ) {
152
+ rimraf ( OUTPUT_DIR , done ) ;
153
+ } ) ;
154
+ } ) ) ;
164
155
165
156
function createStream ( name , content ) {
166
157
// Create a stream with our entry file
0 commit comments