2016-03-29 00:00:32 +03:00
import { Preset , Clean , CleanStylesheets , CleanJavascripts , Copy , Jekyll , CssNano , Sass , RollupEs , RollupUmd , RollupIife , ScssLint , EsLint , Aggregate , Uglify , parallel , series } from 'gulp-pipeline'
2016-03-10 02:08:03 +03:00
2016-03-21 23:13:48 +03:00
// since we are using a docs cwd, we need to grap the source path to watch both docs js and core js
2016-04-29 23:27:08 +03:00
// import findup from 'findup-sync'
// const coreJs = findup('js')
// const coreScss = findup('scss')
2016-03-21 23:13:48 +03:00
2016-03-10 02:08:03 +03:00
const referenceDocNotice =
` $ 1 \n
2016-03-18 01:25:31 +03:00
[ //]: # DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs-docs\n
2016-03-10 02:08:03 +03:00
{ % callout info % } \ n * * Bootstrap Reference Documentation * *
This is a part of the reference documentation from < a href = "http://getbootstrap.com" > Bootstrap < / a > .
2016-08-01 15:17:55 +03:00
It is included here to demonstrate rendering with Bootstrap Material Design default styling .
2016-03-10 02:08:03 +03:00
See the < a href = "/material-design/buttons" > Material Design < / a > s e c t i o n f o r m o r e e l e m e n t s a n d c u s t o m i z a t i o n o p t i o n s .
{ % endcallout % }
\ n \ n$2 `
const copyProcessor = ( content , srcpath ) => { // https://regex101.com/r/cZ7aO8/2
return content
. replace ( /(---[\s\S]+?---)([\s\S]+)/mg , referenceDocNotice ) // insert docs reference
. replace ( /Fancy display heading/ , 'Fancy heading' ) // remove sample text 'display' as this is a particular MD style and is confusing
}
const preset = Preset . baseline ( {
javascripts : {
source : { options : { cwd : 'docs/assets/js/src' } } ,
watch : { options : { cwd : 'docs/assets/js/src' } } ,
test : { options : { cwd : 'docs/assets/js/tests' } } ,
dest : 'docs/dist'
} ,
stylesheets : {
source : { options : { cwd : 'docs/assets/scss' } } ,
watch : { options : { cwd : 'docs/assets/scss' } } ,
dest : 'docs/dist'
2016-03-18 19:34:25 +03:00
} ,
images : {
dest : 'docs/dist'
} ,
postProcessor : {
2016-03-18 20:50:40 +03:00
source : { options : { cwd : 'docs/dist' } } ,
watch : { options : { cwd : 'docs/dist' } } ,
2016-03-18 19:34:25 +03:00
dest : 'docs/dist'
2016-03-10 02:08:03 +03:00
}
} )
const prefix = { task : { prefix : 'docs:' } }
2016-03-21 23:13:48 +03:00
export default function ( gulp , corePreset , options ) {
2016-03-10 02:08:03 +03:00
2016-03-18 20:20:01 +03:00
const js = new Aggregate ( gulp , 'js' ,
series ( gulp ,
2016-03-21 23:38:46 +03:00
parallel ( gulp ,
2016-03-29 00:00:32 +03:00
new CleanJavascripts ( gulp , preset , prefix , { task : false } ) , // just here to trigger jekyll refresh
2016-03-21 23:38:46 +03:00
new EsLint ( gulp , preset , prefix ) ,
2016-03-30 00:36:51 +03:00
new EsLint ( gulp , corePreset , { task : false } ) // lint the core as well - easier for development - and adds watch
2016-03-21 23:38:46 +03:00
) ,
2016-03-18 20:20:01 +03:00
parallel ( gulp ,
new RollupIife ( gulp , preset , prefix , options . rollupConfig , {
options : {
dest : 'docs.iife.js' ,
moduleName : 'docs'
}
} ) ,
new Uglify ( gulp , preset , prefix , {
task : { name : 'vendor:uglify' } ,
source : { options : { cwd : 'docs/assets/js/vendor' } } ,
2016-03-18 22:05:41 +03:00
concat : { dest : 'docs-vendor.min.js' }
2016-03-18 20:20:01 +03:00
} )
2016-03-18 22:05:41 +03:00
) ,
new Uglify ( gulp , preset , prefix , {
task : { name : 'iife:uglify' } ,
2016-03-21 23:13:48 +03:00
source : { glob : '*.iife.js' , options : { ignore : [ '*.iife.min.js' , 'bootstrap*.js' ] } }
2016-03-18 22:05:41 +03:00
} )
2016-03-18 20:20:01 +03:00
) ,
prefix )
2016-03-10 02:08:03 +03:00
2016-03-18 20:20:01 +03:00
const css = new Aggregate ( gulp , 'css' ,
series ( gulp ,
2016-04-30 06:48:59 +03:00
new CleanStylesheets ( gulp , preset , prefix , { task : false } ) , // just here to trigger jekyll refresh
2016-03-21 23:38:46 +03:00
parallel ( gulp ,
new ScssLint ( gulp , preset , prefix , {
source : { glob : [ '**/*.scss' , '!docs.scss' ] } ,
watch : { glob : [ '**/*.scss' , '!docs.scss' ] }
} ) ,
2016-03-30 00:36:51 +03:00
new ScssLint ( gulp , corePreset , { task : false } ) // lint the core as well - easier for development - and adds watch
2016-03-21 23:38:46 +03:00
) ,
2016-03-18 20:20:01 +03:00
new Sass ( gulp , preset , prefix ) ,
new CssNano ( gulp , preset , prefix )
) ,
prefix )
2016-03-10 02:08:03 +03:00
2016-03-18 20:20:01 +03:00
const defaultRecipes = new Aggregate ( gulp , 'default' ,
2016-03-29 01:41:18 +03:00
parallel ( gulp ,
css ,
js
2016-03-18 20:20:01 +03:00
) ,
2016-03-29 01:41:18 +03:00
prefix , { debug : false } )
2016-03-10 02:08:03 +03:00
// docs copy
2016-03-18 20:20:01 +03:00
new Aggregate ( gulp , 'copy:bs-docs' ,
parallel ( gulp ,
new Copy ( gulp , preset , prefix , {
task : false , //{name: 'copy:bs-docs-content'},
source : {
options : { cwd : '../bootstrap/docs/content' } ,
glob : [ '**/*' ]
} ,
dest : 'docs/content/' ,
process : copyProcessor
} ) ,
new Copy ( gulp , preset , prefix , {
task : false , //{name: 'copy:bs-docs-components'},
source : {
options : { cwd : '../bootstrap/docs/components' } ,
glob : [ '**/*' ]
} ,
dest : 'docs/components/' ,
process : copyProcessor
} ) ,
new Copy ( gulp , preset , prefix , {
task : false , //{name: 'copy:bs-docs-scss'},
source : {
options : { cwd : '../bootstrap/docs/assets/scss' } ,
glob : [ '**/*' , '!docs.scss' ] // keep variable customizations
} ,
dest : 'docs/assets/scss/' ,
process : ( content , srcpath ) => {
return content . replace ( /([\s\S]+)/mg , '// DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs-docs\n\n$1' ) ;
}
} ) ,
new Copy ( gulp , preset , prefix , {
task : false , //{name: 'copy:bs-docs-plugins'},
source : {
options : { cwd : '../bootstrap/docs/_plugins' } ,
glob : [ '**/*' , '!bridge.rb' ]
} ,
dest : 'docs/_plugins/'
} ) ,
new Copy ( gulp , preset , prefix , {
task : false , //{name: 'copy:bs-docs-js-vendor'},
source : {
options : { cwd : '../bootstrap/docs/assets/js/vendor' } ,
glob : [
'**/*' ,
'!tether.min.js' ,
'!jquery.min.js'
]
} ,
dest : 'docs/assets/js/vendor/'
} , prefix )
) ,
prefix )
2016-03-17 23:11:07 +03:00
2016-03-18 20:20:01 +03:00
return defaultRecipes
2016-03-10 02:08:03 +03:00
}