uppy/bin/disc.js
Kevin van Zonneveld 764c2ccada
Update Linter (#2796)
* relocate .vscode

* Switch to transloadit linter

* Update .eslintrc.json

* autofix code

* unlink and install eslint-config-transloadit@1.1.1

* Change 0 to "off"

* Don't change 'use strict'

* Do not vertically align

* disable key-spacing

* add import/no-extraneous-dependencies per package

* add more react/a11y warnings

* Revert "autofix code"

This reverts commit 14c8a8cde8.

* add import/no-extraneous-dependencies per example and main package

* autofix code (2)

* Allow devDependencies in ./bin

* Change import/no-extraneous-dependencies to warn again

* upgrade linter

* Set import/no-extraneous-dependencies to warn
2021-03-15 16:25:17 +00:00

44 lines
1.1 KiB
JavaScript

const fs = require('fs')
const path = require('path')
const { PassThrough } = require('stream')
const replace = require('replacestream')
const browserify = require('browserify')
const babelify = require('babelify')
const minify = require('minify-stream')
const disc = require('disc')
const outputPath = path.join(__dirname, '../website/src/disc.html')
function minifyify (filename) {
if (filename.endsWith('.js')) {
return minify({
sourceMap: false,
toplevel: true,
compress: { unsafe: true },
})
}
return new PassThrough()
}
const bundler = browserify(path.join(__dirname, '../packages/uppy/index.js'), {
fullPaths: true,
standalone: 'Uppy',
})
bundler.transform(babelify)
bundler.transform(minifyify, { global: true })
bundler.bundle()
.pipe(disc())
.pipe(prepend('---\nlayout: false\n---\n'))
.pipe(replace('http://', 'https://', { limit: 1 }))
.pipe(fs.createWriteStream(outputPath))
.on('error', (err) => {
throw err
})
function prepend (text) {
const stream = new PassThrough()
stream.write(text)
return stream
}