@@ -23,7 +23,7 @@ module.exports = function(grunt) {
2323 'recess' ,
2424 'clean_bootstrap2_css' ,
2525 'replace' ,
26- 'concat:js_standalone ' ,
26+ 'build_standalone ' ,
2727 'uglify' ,
2828 'clean:post' ,
2929 ] ) ;
@@ -36,10 +36,33 @@ module.exports = function(grunt) {
3636 grunt . registerTask ( 'clean_bootstrap2_css' , 'Cleans CSS rules ocurring before the header comment.' , function ( ) {
3737 var file = 'dist/css/selectize.bootstrap2.css' ;
3838 var source = fs . readFileSync ( file , 'utf8' ) ;
39- fs . writeFileSync ( file , source . replace ( / ^ ( .| \s ) + ?\/ \* / m, '/*' ) , 'utf8' ) ;
39+ grunt . file . write ( file , source . replace ( / ^ ( .| \s ) + ?\/ \* / m, '/*' ) ) ;
4040 grunt . log . writeln ( 'Cleaned "' + file + '".' ) ;
4141 } ) ;
4242
43+ grunt . registerTask ( 'build_standalone' , '' , function ( ) {
44+ var files , i , n , source , name , path , modules = [ ] ;
45+
46+ // amd definitions must be changed to be not anonymous
47+ // @see https://github.com/brianreavis/selectize.js/issues/89
48+ files = [ ] ;
49+ for ( i = 0 , n = files_js_dependencies . length ; i < n ; i ++ ) {
50+ path = files_js_dependencies [ i ] ;
51+ name = path . match ( / ( [ ^ \/ ] + ?) .j s $ / ) [ 1 ] ;
52+ source = grunt . file . read ( path ) . replace ( 'define(factory);' , 'define(\'' + name + '\', factory);' ) ;
53+ modules . push ( source ) ;
54+ }
55+
56+ path = 'dist/js/selectize.js' ;
57+ source = grunt . file . read ( path ) . replace ( / d e f i n e \( ( .* ?) f a c t o r y \) ; / , 'define(\'selectize\', $1factory);' ) ;
58+ modules . push ( source ) ;
59+
60+ // write output
61+ path = 'dist/js/standalone/selectize.js' ;
62+ grunt . file . write ( path , modules . join ( '\n\n' ) ) ;
63+ grunt . log . writeln ( 'Built "' + path + '".' ) ;
64+ } ) ;
65+
4366 var files_js = [
4467 'src/contrib/*.js' ,
4568 'src/*.js' ,
@@ -177,36 +200,6 @@ module.exports = function(grunt) {
177200 'dist/less/selectize.bootstrap3.less'
178201 ]
179202 }
180- } ,
181- js_standalone : {
182- options : {
183- stripBanners : false
184- } ,
185- files : {
186- 'dist/js/standalone/selectize.js' : ( function ( ) {
187- var files , i , n , source , name , path ;
188-
189- // amd definitions must be changed to be not anonymous
190- // @see https://github.com/brianreavis/selectize.js/issues/89
191- path = 'dist/js/selectize.js' ;
192- source = fs . readFileSync ( path , 'utf8' ) . replace ( / d e f i n e \( ( .* ?) f a c t o r y \) ; / , 'define(\'selectize\', $1factory);' ) ;
193- fs . writeFileSync ( 'selectize.tmp.js' , source , 'utf8' ) ;
194-
195- // dependencies
196- files = [ ] ;
197- for ( i = 0 , n = files_js_dependencies . length ; i < n ; i ++ ) {
198- path = files_js_dependencies [ i ] ;
199- name = path . match ( / ( [ ^ \/ ] + ?) .j s $ / ) [ 1 ] ;
200- source = fs . readFileSync ( path , 'utf8' ) . replace ( 'define(factory);' , 'define(\'' + name + '\', factory);' ) ;
201- fs . writeFileSync ( path , source , 'utf8' ) ;
202-
203- files . push ( path ) ;
204- }
205-
206- files . push ( 'selectize.tmp.js' ) ;
207- return files ;
208- } ) ( )
209- }
210203 }
211204 } ,
212205 uglify : {
0 commit comments