docsify/build/build.js

66 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-11-20 22:29:36 +08:00
var rollup = require('rollup')
var buble = require('rollup-plugin-buble')
2016-11-22 22:46:44 +08:00
var commonjs = require('rollup-plugin-commonjs')
var nodeResolve = require('rollup-plugin-node-resolve')
var uglify = require('rollup-plugin-uglify')
2017-02-09 00:19:10 +08:00
var isProd = process.argv[process.argv.length - 1] !== '--dev'
2016-11-20 22:29:36 +08:00
2016-11-22 22:46:44 +08:00
var build = function (opts) {
2016-11-20 22:29:36 +08:00
rollup
.rollup({
2016-11-22 22:46:44 +08:00
entry: 'src/' + opts.entry,
plugins: [buble()].concat(opts.plugins || [])
2016-11-20 22:29:36 +08:00
})
.then(function (bundle) {
2016-11-22 22:46:44 +08:00
var dest = 'lib/' + (opts.output || opts.entry)
console.log(dest)
2016-11-20 22:29:36 +08:00
bundle.write({
format: 'iife',
2017-02-09 00:19:10 +08:00
moduleName: opts.moduleName || 'D',
2016-11-22 22:46:44 +08:00
dest: dest
2016-11-20 22:29:36 +08:00
})
})
.catch(function (err) {
console.error(err)
})
2016-11-20 22:29:36 +08:00
}
2016-11-22 22:46:44 +08:00
build({
2017-02-17 23:09:09 +08:00
entry: 'core/index.js',
2016-11-26 14:28:21 +08:00
output: 'docsify.js',
plugins: [commonjs(), nodeResolve()]
2016-11-22 22:46:44 +08:00
})
2017-02-17 23:09:09 +08:00
// build({
// entry: 'plugins/search.js',
// output: 'plugins/search.js',
// moduleName: 'D.Search'
// })
// build({
// entry: 'plugins/ga.js',
// output: 'plugins/ga.js',
// moduleName: 'D.GA'
// })
if (isProd) {
build({
entry: 'index.js',
output: 'docsify.min.js',
plugins: [commonjs(), nodeResolve(), uglify()]
})
build({
entry: 'plugins/search.js',
output: 'plugins/search.min.js',
moduleName: 'D.Search',
plugins: [uglify()]
})
build({
entry: 'plugins/ga.js',
output: 'plugins/ga.min.js',
moduleName: 'D.GA',
plugins: [uglify()]
})
}