package: package refactoring
This commit is contained in:
parent
1b2da1750a
commit
d0cc7f51aa
145 changed files with 175 additions and 847 deletions
49
scripts/build.js
Normal file
49
scripts/build.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
var browserify = require('browserify'),
|
||||
exorcist = require('exorcist'),
|
||||
licensify = require('licensify'),
|
||||
fs = require('fs'),
|
||||
path = require('path')
|
||||
|
||||
|
||||
module.exports = (opt) => {
|
||||
|
||||
var {input, output, options, ignore, exclude, transforms, plugins} = opt,
|
||||
inputPath = path.resolve(__dirname + '/' + input),
|
||||
outputPath = path.resolve(__dirname + '/' + output),
|
||||
b
|
||||
|
||||
if (!plugins) plugins = []
|
||||
if (!plugins.includes(licensify)) plugins.push(licensify)
|
||||
|
||||
b = browserify(inputPath, options)
|
||||
|
||||
if (ignore) b.ignore(ignore)
|
||||
if (exclude) b.exclude(exclude)
|
||||
|
||||
for (var plugin of plugins) {
|
||||
b.plugin(plugin)
|
||||
}
|
||||
|
||||
if (transforms) {
|
||||
for (var transform of transforms) {
|
||||
var [t, opts] = transform
|
||||
b.transform(t, opts)
|
||||
}
|
||||
}
|
||||
|
||||
function bundle() {
|
||||
|
||||
var output = b.bundle()
|
||||
|
||||
output = output.pipe(exorcist(outputPath + '.map'))
|
||||
output.pipe(fs.createWriteStream(outputPath))
|
||||
|
||||
return output
|
||||
|
||||
}
|
||||
|
||||
bundle.b = b
|
||||
|
||||
return bundle
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue