2016-03-10 02:08:03 +03:00
|
|
|
import {Preset, Clean, Copy, Jekyll, MinifyCss, Sass, RollupEs, RollupUmd, RollupIife, ScssLint, EsLint, TaskSeries, Uglify} from 'gulp-pipeline/src/index'
|
|
|
|
|
|
|
|
const referenceDocNotice =
|
|
|
|
`$1\n
|
|
|
|
[//]: # DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by gulp docs:copy:bs\n
|
|
|
|
{% callout info %}\n**Bootstrap Reference Documentation**
|
|
|
|
This is a part of the reference documentation from <a href="http://getbootstrap.com">Bootstrap</a>.
|
|
|
|
It is included here to demonstrate rendering with Material Design for Bootstrap default styling.
|
|
|
|
See the <a href="/material-design/buttons">Material Design</a> section for more elements and customization options.
|
|
|
|
{% 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'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const prefix = {task: {prefix: 'docs:'}}
|
|
|
|
|
|
|
|
export default function (gulp, options) {
|
|
|
|
|
|
|
|
let javascripts = [
|
|
|
|
new RollupIife(gulp, preset, prefix, options.rollupConfig, {
|
2016-03-10 19:12:16 +03:00
|
|
|
options: {
|
|
|
|
dest: 'docs.iife.js',
|
|
|
|
moduleName: 'docs'
|
|
|
|
}
|
|
|
|
}),
|
2016-03-10 02:08:03 +03:00
|
|
|
new Uglify(gulp, preset, prefix, {
|
|
|
|
task: {name: 'vendor:uglify'},
|
|
|
|
source: {options: {cwd: 'docs/assets/js/vendor'}},
|
|
|
|
options: {dest: 'docs-vendor.min.js'}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
|
|
|
|
let eslint = new EsLint(gulp, preset, prefix)
|
|
|
|
let scsslint = new ScssLint(gulp, preset, prefix, {
|
|
|
|
source: {glob: ['**/*.scss', '!docs.scss']},
|
|
|
|
watch: {glob: ['**/*.scss', '!docs.scss']}
|
|
|
|
})
|
|
|
|
let linters = [scsslint, eslint]
|
|
|
|
let sass = new Sass(gulp, preset, prefix)
|
|
|
|
|
|
|
|
new TaskSeries(gulp, 'default', [
|
2016-03-10 02:50:43 +03:00
|
|
|
new Clean(gulp, preset, prefix),
|
2016-03-10 02:08:03 +03:00
|
|
|
linters,
|
2016-03-10 19:12:16 +03:00
|
|
|
sass,
|
|
|
|
javascripts,
|
2016-03-10 02:08:03 +03:00
|
|
|
new MinifyCss(gulp, preset, prefix)
|
|
|
|
], prefix)
|
|
|
|
new TaskSeries(gulp, 'lint', linters, prefix)
|
|
|
|
new TaskSeries(gulp, 'js', [eslint, javascripts], prefix)
|
|
|
|
new TaskSeries(gulp, 'css', [scsslint, sass], prefix)
|
|
|
|
|
|
|
|
// docs copy
|
|
|
|
new TaskSeries(gulp, 'copy:bs-docs', [
|
|
|
|
new Copy(gulp, preset, prefix, {
|
|
|
|
task: {name: 'copy:bs-docs-content'},
|
|
|
|
source: {
|
|
|
|
options: {cwd: '../bootstrap/docs/content'},
|
|
|
|
glob: ['**/*']
|
|
|
|
},
|
|
|
|
dest: 'docs/content/',
|
|
|
|
process: copyProcessor
|
|
|
|
}),
|
|
|
|
new Copy(gulp, preset, prefix, {
|
|
|
|
task: {name: 'copy:bs-docs-components'},
|
|
|
|
source: {
|
|
|
|
options: {cwd: '../bootstrap/docs/components'},
|
|
|
|
glob: ['**/*']
|
|
|
|
},
|
|
|
|
dest: 'docs/components/',
|
|
|
|
process: copyProcessor
|
|
|
|
}),
|
|
|
|
new Copy(gulp, preset, prefix, {
|
|
|
|
task: {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\n\n$1');
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new Copy(gulp, preset, prefix, {
|
|
|
|
task: {name: 'copy:bs-docs-plugins'},
|
|
|
|
source: {
|
|
|
|
options: {cwd: '../bootstrap/docs/_plugins'},
|
|
|
|
glob: ['**/*', '!bridge.rb']
|
|
|
|
},
|
|
|
|
dest: 'docs/_plugins/'
|
|
|
|
}),
|
|
|
|
new Copy(gulp, preset, prefix, {
|
|
|
|
task: {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)
|
|
|
|
])
|
|
|
|
}
|