mdb-ui-kit/gulpfile.babel.js

165 lines
3.9 KiB
JavaScript
Raw Normal View History

import {Preset, Clean, Copy, Jekyll, CssNano, Prepublish, PublishBuild, PublishGhPages, Sass, RollupUmd, RollupIife, ScssLint, EsLint, Aggregate, Uglify, series, parallel} from 'gulp-pipeline'
2016-03-19 03:30:02 +03:00
2016-03-01 19:49:36 +03:00
import gulp from 'gulp'
import findup from 'findup-sync'
2016-03-02 01:57:24 +03:00
import pkg from './package.json'
import moment from 'moment'
import gulpDocs from './gulp-docs'
2016-03-01 19:49:36 +03:00
const node_modules = findup('node_modules')
2016-03-01 19:49:36 +03:00
2016-03-18 01:22:27 +03:00
// we have a lot of aggregates, which add listeners
gulp.setMaxListeners(20)
const preset = Preset.baseline({
2016-03-01 19:49:36 +03:00
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'}}
2016-03-18 02:50:12 +03:00
},
postProcessor: {
dest: 'dist' //'dist/digest'
2016-03-01 19:49:36 +03:00
}
})
// 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
const rollupConfig = {
options: {
external: [
'anchor-js',
'clipboard'
],
globals: {
'anchor-js': 'anchors',
clipboard: 'Clipboard'
2016-03-02 01:57:24 +03:00
},
2016-03-02 23:35:46 +03:00
banner: `/*!
2016-03-02 01:57:24 +03:00
* 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
}
}
}
const copyJsToDocs = new Copy(gulp, preset, {
task: {name: 'dist:js->docs'},
source: {
options: {cwd: 'dist'},
glob: ['*.iife*.js']
},
dest: 'docs/dist/'
})
const copyCssToDocs = new Copy(gulp, preset, {
task: {name: 'dist:css->docs'},
source: {
options: {cwd: 'dist'},
glob: ['*.css']
},
dest: 'docs/dist/'
})
const js = new Aggregate(gulp, 'js',
series(gulp,
new EsLint(gulp, preset),
parallel(gulp,
new RollupUmd(gulp, preset, rollupConfig, {
options: {
dest: 'bootstrap-material-design.umd.js',
moduleName: 'bootstrapMaterialDesign'
}
}),
new RollupIife(gulp, preset, rollupConfig, {
options: {
dest: 'bootstrap-material-design.iife.js',
moduleName: 'bootstrapMaterialDesign'
}
})
),
new Uglify(gulp, preset, {
task: {name: 'iife:uglify'},
source: { glob: '*.iife.js' }
}),
copyJsToDocs
)
2016-03-18 02:50:12 +03:00
)
2016-03-01 19:49:36 +03:00
const css = new Aggregate(gulp, 'css',
series(gulp,
new ScssLint(gulp, preset),
new Sass(gulp, preset),
new CssNano(gulp, preset),
copyCssToDocs
)
)
const defaultRecipes = new Aggregate(gulp, 'default', series(gulp,
2016-03-01 19:49:36 +03:00
new Clean(gulp, preset),
2016-03-17 23:11:07 +03:00
parallel(gulp,
css,
js
2016-03-18 02:50:12 +03:00
)
))
// load all docs tasks
let docsDefaultRecipes = gulpDocs(gulp, preset, {rollupConfig: rollupConfig})
2016-03-21 23:38:46 +03:00
// all - both core and docs
const all = new Aggregate(gulp, 'all',
2016-03-21 23:38:46 +03:00
parallel(gulp,
defaultRecipes,
docsDefaultRecipes
)
)
// publish
new Aggregate(gulp, 'publish',
2016-03-09 19:23:01 +03:00
series(gulp,
new Prepublish(gulp, preset), // asserts committed
2016-03-09 22:37:05 +03:00
all,
// ^^^docs:default cleans docs/dist, so we need to re-copy dist to docs in this scenario
parallel(gulp, copyCssToDocs, copyJsToDocs),
2016-03-10 02:50:43 +03:00
new Jekyll(gulp, preset, {options: {raw: 'baseurl: "/bootstrap-material-design"'}}),
2016-03-10 02:50:43 +03:00
new PublishBuild(gulp, preset, {
npm: {
bump: false,
publish: false
}
}),
new PublishGhPages(gulp, preset, {
options: {
remote: {
repo: 'git@github.com:rosskevin/bootstrap-material-design.git' // FIXME: temporary, remove this option when we are deploying to our home repo
}
}
})
)
)
2016-03-18 01:22:27 +03:00