mdb-ui-kit/gulpfile.babel.js

157 lines
4.5 KiB
JavaScript
Raw Normal View History

2016-03-02 01:43:08 +03:00
import {Preset, Clean, MinifyCss, Sass, RollupEs, RollupUmd, RollupIife, ScssLint, EsLint, TaskSeries, Uglify} from 'gulp-pipeline/src/index'
2016-03-01 19:49:36 +03:00
// debug the project source - remove for repo
//import {Clean, CleanDigest, Images, MinifyCss, Sass, RollupIife, ScssLint, EsLint, Rev, TaskSeries} from 'gulp-pipeline'
//import Preset from '../../../gulp-pipeline/src/preset'
import extend from 'extend'
import stringify from 'stringify-object'
import gulp from 'gulp'
import findup from 'findup-sync'
const node_modules = findup('node_modules')
2016-03-02 01:57:24 +03:00
import pkg from './package.json'
import moment from 'moment'
2016-03-01 19:49:36 +03:00
let preset = Preset.baseline({
javascripts: {
source: {options: {cwd: 'js/src'}},
2016-03-01 19:49:36 +03:00
watch: {options: {cwd: 'js/src'}},
test: {options: {cwd: 'js/tests'}}
},
stylesheets: {
source: {options: {cwd: 'scss'}},
watch: {options: {cwd: 'scss'}}
},
images: {
source: {options: {cwd: 'images'}},
watch: {options: {cwd: 'images'}}
}
})
// When converting non-modular dependencies into usable ones using rollup-plugin-commonjs, if they don't have properly read exports add them here.
let namedExports = {}
//namedExports[`${node_modules}/corejs-typeahead/dist/bloodhound.js`] = ['Bloodhound']
//namedExports[`${node_modules}/anchor-js/anchor.js`] = ['AnchorJS']
2016-03-01 19:49:36 +03:00
let rollupConfig = {
2016-03-02 01:43:08 +03:00
//debug: true,
options: {
external: [
'anchor-js',
'clipboard'
],
globals: {
'anchor-js': 'anchors',
clipboard: 'Clipboard'
2016-03-02 01:57:24 +03:00
},
banner:
`/*!
* Bootstrap Material Design v${pkg.version} (${pkg.homepage})
* Copyright 2014-${moment().format("YYYY")} ${pkg.author}
* Licensed under MIT (https://github.com/FezVrasta/bootstrap-material-design/blob/master/LICENSE)
*/`
},
2016-03-01 19:49:36 +03:00
commonjs: {
options: {
namedExports: namedExports,
2016-03-01 19:49:36 +03:00
}
}
}
let rollups = [
new RollupEs(gulp, preset, extend(true, {}, rollupConfig, {options: {dest: 'bootstrap-material-design.es.js'}})),
new RollupUmd(gulp, preset, extend(true, {}, rollupConfig, {
options: {
dest: 'bootstrap-material-design.umd.js',
moduleName: 'bootstrapMaterialDesign'
}
})),
new RollupIife(gulp, preset, extend(true, {}, rollupConfig, {
options: {
dest: 'bootstrap-material-design.iife.js',
moduleName: 'bootstrapMaterialDesign'
}
})),
2016-03-01 19:49:36 +03:00
]
let eslint = new EsLint(gulp, preset)
let scsslint = new ScssLint(gulp, preset)
let sass = new Sass(gulp, preset)
2016-03-01 19:49:36 +03:00
let lint = [scsslint, eslint]
// instantiate ordered array of recipes (for each instantiation the tasks will be created e.g. sass and sass:watch)
let recipes = [
new Clean(gulp, preset),
lint,
[
sass,
rollups
],
new MinifyCss(gulp, preset)
2016-03-01 19:49:36 +03:00
]
// Simple helper to create the default and watch tasks as a sequence of the recipes already defined
new TaskSeries(gulp, 'default', recipes)
new TaskSeries(gulp, 'lint', lint)
new TaskSeries(gulp, 'js', [eslint, rollups])
new TaskSeries(gulp, 'css', [scsslint, sass])
2016-03-02 01:57:24 +03:00
/**
* DOCS
*/
const referenceDocNotice =
`$1\n
[//]: # DO NOT EDIT IT WILL BE OVERWRITTEN - copy of bootstrap documentation generated by grunt docs-copy-bootstrap-docs\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`
let docsPreset = 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 docsConfig = {task: {prefix: 'docs:'}}
let docs = [
2016-03-02 01:43:08 +03:00
[
new ScssLint(gulp, docsPreset, extend(true, {}, docsConfig, {
source: {glob: ['**/*.scss', '!docs.scss']},
watch: {glob: ['**/*.scss', '!docs.scss']}
})),
new EsLint(gulp, docsPreset, docsConfig)
],
[
new RollupIife(gulp, docsPreset, extend(true, {}, docsConfig, rollupConfig, {
options: {
dest: 'docs.iife.js',
moduleName: 'docs'
}
})),
new Uglify(gulp, docsPreset, extend(true, {}, docsConfig, {
task: {name: 'vendor:uglify'},
source: {options: {cwd: 'docs/assets/js/vendor'}},
options: {dest: 'docs-vendor.min.js'}
})),
new Sass(gulp, docsPreset, docsConfig)
]
]