mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-22 17:58:05 +00:00
Add bundle for transloadit preset.
This commit is contained in:
parent
dd718ac02e
commit
99e08ae855
3 changed files with 35 additions and 17 deletions
|
|
@ -1,4 +1,3 @@
|
|||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var chalk = require('chalk')
|
||||
var mkdirp = require('mkdirp')
|
||||
|
|
@ -7,18 +6,12 @@ var tinyify = require('tinyify')
|
|||
var browserify = require('browserify')
|
||||
var exorcist = require('exorcist')
|
||||
|
||||
var distPath = './packages/uppy/dist'
|
||||
var srcPath = './packages/uppy'
|
||||
|
||||
function handleErr (err) {
|
||||
console.error(chalk.red('✗ Error:'), chalk.red(err.message))
|
||||
}
|
||||
|
||||
function buildUppyBundle (minify) {
|
||||
var src = path.join(srcPath, 'bundle.js')
|
||||
var bundleFile = minify ? 'uppy.min.js' : 'uppy.js'
|
||||
|
||||
var b = browserify(src, { debug: true, standalone: 'Uppy' })
|
||||
function buildBundle (srcFile, bundleFile, { minify = false } = {}) {
|
||||
var b = browserify(srcFile, { debug: true, standalone: 'Uppy' })
|
||||
if (minify) {
|
||||
b.plugin(tinyify)
|
||||
}
|
||||
|
|
@ -27,8 +20,8 @@ function buildUppyBundle (minify) {
|
|||
|
||||
return new Promise(function (resolve, reject) {
|
||||
b.bundle()
|
||||
.pipe(exorcist(path.join(distPath, bundleFile + '.map')))
|
||||
.pipe(fs.createWriteStream(path.join(distPath, bundleFile), 'utf8'))
|
||||
.pipe(exorcist(bundleFile + '.map'))
|
||||
.pipe(fs.createWriteStream(bundleFile), 'utf8')
|
||||
.on('error', handleErr)
|
||||
.on('finish', function () {
|
||||
if (minify) {
|
||||
|
|
@ -41,9 +34,28 @@ function buildUppyBundle (minify) {
|
|||
})
|
||||
}
|
||||
|
||||
mkdirp.sync(distPath)
|
||||
mkdirp.sync('./packages/uppy/dist')
|
||||
mkdirp.sync('./packages/@uppy/transloadit-preset/dist')
|
||||
|
||||
Promise.all([buildUppyBundle(), buildUppyBundle(true)])
|
||||
.then(function () {
|
||||
console.info(chalk.yellow('✓ JS Bundle 🎉'))
|
||||
})
|
||||
Promise.all([
|
||||
buildBundle(
|
||||
'./packages/uppy/bundle.js',
|
||||
'./packages/uppy/dist/uppy.js'
|
||||
),
|
||||
buildBundle(
|
||||
'./packages/uppy/bundle.js',
|
||||
'./packages/uppy/dist/uppy.min.js',
|
||||
{ minify: true }
|
||||
),
|
||||
buildBundle(
|
||||
'./packages/@uppy/transloadit-preset/bundle.js',
|
||||
'./packages/@uppy/transloadit-preset/dist/transloadit.js'
|
||||
),
|
||||
buildBundle(
|
||||
'./packages/@uppy/transloadit-preset/bundle.js',
|
||||
'./packages/@uppy/transloadit-preset/dist/transloadit.min.js',
|
||||
{ minify: true }
|
||||
)
|
||||
]).then(function () {
|
||||
console.info(chalk.yellow('✓ JS Bundle 🎉'))
|
||||
})
|
||||
|
|
|
|||
4
packages/@uppy/transloadit-preset/bundle.js
Normal file
4
packages/@uppy/transloadit-preset/bundle.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
require('es6-promise/auto')
|
||||
require('whatwg-fetch')
|
||||
|
||||
module.exports = require('./')
|
||||
|
|
@ -37,6 +37,8 @@
|
|||
"@uppy/transloadit": "0.27.5",
|
||||
"@uppy/url": "0.27.5",
|
||||
"@uppy/utils": "0.27.1",
|
||||
"@uppy/webcam": "0.27.4"
|
||||
"@uppy/webcam": "0.27.4",
|
||||
"es6-promise": "^4.2.5",
|
||||
"whatwg-fetch": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue