Skip to content

Commit

Permalink
Merge pull request #332 from goto-bus-stop/feature/min-disc
Browse files Browse the repository at this point in the history
website: Minify bundle for `disc`
  • Loading branch information
goto-bus-stop committed Sep 11, 2017
2 parents 47dab77 + 76e1d0e commit e59c5ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 43 deletions.
20 changes: 0 additions & 20 deletions bin/build-bundle

This file was deleted.

21 changes: 0 additions & 21 deletions bin/build-bundle-locales

This file was deleted.

31 changes: 31 additions & 0 deletions bin/disc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const fs = require('fs')
const path = require('path')
const { PassThrough } = require('stream')
const browserify = require('browserify')
const babelify = require('babelify')
const minifyify = require('minifyify')
const disc = require('disc')

const outputPath = path.join(__dirname, '../website/src/disc.html')

const bundler = browserify(path.join(__dirname, '../src/index.js'), {
fullPaths: true,
standalone: 'Uppy'
})

bundler.plugin(minifyify, { map: false })
bundler.transform(babelify)

bundler.bundle()
.pipe(disc())
.pipe(prepend('---\nlayout: false\n---\n'))
.pipe(fs.createWriteStream(outputPath))
.on('error', (err) => {
throw err
})

function prepend (text) {
const stream = new PassThrough()
stream.write(text)
return stream
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"build:css": "node ./bin/build-css.js",
"build:gzip": "node ./bin/gzip.js",
"size": "echo 'JS Bundle mingz:' && cat ./dist/uppy.min.js | gzip | wc -c && echo 'CSS Bundle mingz:' && cat ./dist/uppy.min.css | gzip | wc -c",
"build:bundle:fullpath": "env OUT=uppy-fp.js ./bin/build-bundle --full-paths",
"build:js": "npm-run-all build:bundle build:lib",
"build:lib": "babel --version && babel src --source-maps -d lib",
"build": "npm-run-all --parallel build:js build:css --serial build:gzip size",
Expand Down Expand Up @@ -133,7 +132,7 @@
"web:clean": "cd website && ./node_modules/.bin/hexo clean",
"web:deploy": "npm-run-all web:install web:disc web:build && ./bin/web-deploy",
"web:generated-docs": "cd website && node node_modules/documentation/bin/documentation.js readme ../src/index.js --readme-file=src/docs/api.md --section 'Uppy Core & Plugins' -q --github -c doc-order.json",
"web:disc": "npm run build:bundle:fullpath && discify dist/uppy-fp.js --output website/src/_disc.html && echo '---\nlayout: false\n---\n' |cat - website/src/_disc.html > website/src/disc.html && rm website/src/_disc.html",
"web:disc": "node ./bin/disc.js",
"web:install": "cd website && npm install",
"web:bundle:update:watch": "onchange 'dist/**/*.css' 'dist/**/*.js' --initial --verbose -- node website/update.js",
"web:examples:watch": "cd website && node build-examples.js watch",
Expand Down

0 comments on commit e59c5ea

Please sign in to comment.