2016-03-19 03:35:22 +03:00
|
|
|
import {Preset, Clean, Copy, Jekyll, CssNano, Prepublish, PublishBuild, PublishGhPages, Sass, RollupEs, 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'
|
2016-03-10 02:08:03 +03:00
|
|
|
import gulpDocs from './gulp-docs'
|
2016-03-01 19:49:36 +03:00
|
|
|
|
2016-03-10 02:08:03 +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)
|
|
|
|
|
2016-03-18 19:34:25 +03:00
|
|
|
const preset = Preset.baseline({
|
2016-03-01 19:49:36 +03:00
|
|
|
javascripts: {
|
2016-03-02 01:07:46 +03:00
|
|
|
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']
|
2016-03-02 01:07:46 +03:00
|
|
|
//namedExports[`${node_modules}/anchor-js/anchor.js`] = ['AnchorJS']
|
2016-03-01 19:49:36 +03:00
|
|
|
|
2016-03-18 19:34:25 +03:00
|
|
|
const rollupConfig = {
|
2016-03-02 01:07:46 +03:00
|
|
|
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-02 01:07:46 +03:00
|
|
|
},
|
2016-03-01 19:49:36 +03:00
|
|
|
commonjs: {
|
|
|
|
options: {
|
2016-03-02 01:07:46 +03:00
|
|
|
namedExports: namedExports,
|
2016-03-01 19:49:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 19:34:25 +03:00
|
|
|
const copyJsToDocs = new Copy(gulp, preset, {
|
|
|
|
task: {name: 'dist:js->docs'},
|
|
|
|
source: {
|
|
|
|
options: {cwd: 'dist'},
|
2016-03-19 03:42:47 +03:00
|
|
|
glob: ['*.iife*.js']
|
2016-03-18 19:34:25 +03:00
|
|
|
},
|
|
|
|
dest: 'docs/dist/'
|
|
|
|
})
|
|
|
|
|
|
|
|
const copyCssToDocs = new Copy(gulp, preset, {
|
|
|
|
task: {name: 'dist:css->docs'},
|
|
|
|
source: {
|
|
|
|
options: {cwd: 'dist'},
|
|
|
|
glob: ['*.css']
|
|
|
|
},
|
|
|
|
dest: 'docs/dist/'
|
|
|
|
})
|
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
const js = new Aggregate(gulp, 'js',
|
|
|
|
series(gulp,
|
|
|
|
new EsLint(gulp, preset),
|
|
|
|
parallel(gulp,
|
|
|
|
new RollupEs(gulp, preset, rollupConfig, {options: {dest: 'bootstrap-material-design.es.js'}}),
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
),
|
2016-03-18 22:05:41 +03:00
|
|
|
new Uglify(gulp, preset, {
|
|
|
|
task: {name: 'iife:uglify'},
|
|
|
|
source: { glob: '*.iife.js' }
|
|
|
|
}),
|
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
copyJsToDocs
|
|
|
|
)
|
2016-03-18 02:50:12 +03:00
|
|
|
)
|
2016-03-01 19:49:36 +03:00
|
|
|
|
2016-03-18 20:00:51 +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,
|
2016-03-18 20:00:51 +03:00
|
|
|
css,
|
|
|
|
js
|
2016-03-18 02:50:12 +03:00
|
|
|
)
|
2016-03-18 20:00:51 +03:00
|
|
|
))
|
2016-03-02 01:07:46 +03:00
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
// load all docs tasks
|
2016-03-21 23:13:48 +03:00
|
|
|
let docsDefaultRecipes = gulpDocs(gulp, preset, {rollupConfig: rollupConfig})
|
2016-03-02 01:07:46 +03:00
|
|
|
|
2016-03-21 23:38:46 +03:00
|
|
|
|
|
|
|
// build - both core and docs
|
|
|
|
const build = new Aggregate(gulp, 'build',
|
|
|
|
parallel(gulp,
|
|
|
|
defaultRecipes,
|
|
|
|
docsDefaultRecipes
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
// publish
|
|
|
|
new Aggregate(gulp, 'publish',
|
2016-03-09 19:23:01 +03:00
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
series(gulp,
|
|
|
|
new Prepublish(gulp, preset), // asserts committed
|
2016-03-09 22:37:05 +03:00
|
|
|
|
2016-03-21 23:38:46 +03:00
|
|
|
build,
|
2016-03-18 19:34:25 +03:00
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
// ^^^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
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
new Jekyll(gulp, preset, {options: {raw: 'baseurl: "/bootstrap-material-design"'}}),
|
2016-03-10 02:50:43 +03:00
|
|
|
|
2016-03-18 20:00:51 +03:00
|
|
|
new PublishBuild(gulp, preset, {
|
|
|
|
npm: {
|
|
|
|
bump: false,
|
|
|
|
publish: false
|
2016-03-18 19:34:25 +03:00
|
|
|
}
|
2016-03-18 20:00:51 +03:00
|
|
|
}),
|
|
|
|
|
|
|
|
new PublishGhPages(gulp, preset, {
|
2016-03-18 22:32:26 +03:00
|
|
|
debug: true,
|
2016-03-18 20:00:51 +03:00
|
|
|
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
|
|
|
|