Kaynağa Gözat

Updated build system

Harry Hedger 9 yıl önce
ebeveyn
işleme
1f8cf50da8
12 değiştirilmiş dosya ile 30 ekleme ve 112 silme
  1. 0 1
      Transloadit.js
  2. 0 15
      bin/build
  3. 1 0
      bin/build-css
  4. 11 0
      bin/build-umd
  5. 0 61
      bin/builder
  6. 0 1
      core.js
  7. 0 4
      index.js
  8. 13 11
      package.json
  9. 0 1
      plugins.js
  10. 0 8
      src/create.js
  11. 5 10
      src/index.js
  12. 0 0
      src/scss/index.scss

+ 0 - 1
Transloadit.js

@@ -1 +0,0 @@
-module.exports = require('./lib/core');

+ 0 - 15
bin/build

@@ -1,15 +0,0 @@
-CORESRC="src/core/index.js"
-COREDIST="dist/uppy.js"
-
-PLUGINSRC="src/plugins/index.js"
-PLUGINDIST="dist/uppy-plugins.js"
-
-CORENAME="Uppy"
-PLUGINNAME="UppyPlugin"
-
-TRANSFORMS="[ babelify ]"
-
-rm -rf dist
-mkdir dist
-browserify $CORESRC -o $COREDIST --standalone $CORENAME -t $TRANSFORMS
-browserify $PLUGINSRC -o $PLUGINDIST --standalone $PLUGINNAME -t $TRANSFORMS

+ 1 - 0
bin/build-css

@@ -0,0 +1 @@
+node_modules/.bin/node-sass src/scss/index.scss -o dist/uppy.css

+ 11 - 0
bin/build-umd

@@ -0,0 +1,11 @@
+SRC="src/index.js"
+OUT="uppy.js"
+
+OUTDIR="dist"
+TRANSFORMS="[ babelify ]"
+FLAGS="-t [ babelify ] --standalone Uppy"
+
+rm -rf $OUTDIR
+mkdir $OUTDIR
+
+browserify $SRC $FLAGS > $OUTDIR/$OUT

+ 0 - 61
bin/builder

@@ -1,61 +0,0 @@
-#!/bin/bash
-
-# Setup
-#######################################################
-transformations="[ babelify ]"
-toolpath="${1:-node_modules/.bin/browserify}"
-toolname="$(basename "${toolpath}")"
-
-if [ "${toolname}" = "node-sass" ]; then
-  srcExtension="scss"
-  dstExtension="css"
-else
-  srcExtension="js"
-  dstExtension="js"
-fi
-
-if [ "${toolname}" = "watchify" ]; then
-  extraArgs="-t ${transformations} --ignore-watch=**/build/** --verbose"
-elif [ "${toolname}" = "browserify" ]; then
-  extraArgs="-t ${transformations} --ignore-watch=**/build/** --verbose"
-else
-  extraArgs=""
-fi
-
-
-bundleTarget="build/uppy.${dstExtension}"
-
-# Individual files, built seperately
-#######################################################
-allSourceFiles=""
-for src in $(find src -name "*.${srcExtension}" -type f); do
-  allSourceFiles="${allSourceFiles} ${src}"
-  dst="build/$(basename $(dirname ${src}))/$(basename ${src})"
-  echo "--> ${src} -> ${dst}"
-
-  # Argument should be `browserify`, or `node-sass`
-  if [ "${toolname}" = "node-sass" ]; then
-    "${toolpath}" "${src}" "${dst}" ${extraArgs}
-  else
-    "${toolpath}" "${src}" -o "${dst}" ${extraArgs}
-  fi
-done
-
-# All files in one bundle
-#######################################################
-echo "--> *.${srcExtension} -> ${bundleTarget}"
-if [ "${toolname}" = "node-sass" ]; then
-  "${toolpath}" ${allSourceFiles} "${bundleTarget}" ${extraArgs}
-else
-  "${toolpath}" ${allSourceFiles} -o "${bundleTarget}" ${extraArgs}
-fi
-
-# Install into examples
-for path in $(find examples -maxdepth 1 -mindepth 1 -type d); do
-  exampleProject="$(basename "${path}")"
-  rsync \
-    -ai \
-    --exclude='.DS_Store' \
-    --exclude='.empty' \
-  build/ "examples/${exampleProject}/static/uppy"
-done

+ 0 - 1
core.js

@@ -1 +0,0 @@
-module.exports = require('./lib/core')

+ 0 - 4
index.js

@@ -1,4 +0,0 @@
-module.exports = {
-  core: require('./core'),
-  plugins: require('./plugins')
-}

+ 13 - 11
package.json

@@ -2,22 +2,24 @@
   "name": "uppy",
   "version": "0.0.1",
   "description": "Almost as cute as a Puppy :dog:",
-  "main": "index.js",
+  "main": "src/index.js",
   "scripts": {
-    "browser-sync": "browser-sync start --config bs-config.js",
-    "build": "npm run build:js && npm run build:css",
-    "build:css": "bin/builder node_modules/.bin/node-sass",
-    "build:js": "bin/builder node_modules/.bin/browserify",
+    "build": "npm run build:lib && npm run build:umd && npm run build:umd:min && npm run build:css",
+    "build:css": "bin/build-css",
     "build:lib": "rm -rf ./lib && babel src -d lib --stage 0",
+    "build:umd": "./bin/build-umd",
+    "build:umd:min": "./bin/build-umd",
     "build:examples": "examples/buildAll node_modules/.bin/browserify",
-    "clean": "rm -rf lib/**/*.js && rm -rf lib/**/*.css",
+    "clean": "rm -rf lib && rm -rf dist",
     "lint": "eslint src/**/*.js",
-    "phantom-test": "zuul test/spec/upload.js --phantom",
-    "preview": "npm run watch & npm run browser-sync",
+    "preview": "npm run watch & npm run server",
+    "server": "browser-sync start --config bs-config.js",
     "test": "bin/test",
-    "watch": "npm run watch:css && npm run watch:js",
-    "watch:css": "nodemon -e scss -x \"npm run build:css\"",
-    "watch:js": "bin/builder node_modules/.bin/watchify"
+    "test:phantom": "zuul test/spec/upload.js --phantom",
+    "watch": "npm run watch:css & npm run watch:js",
+    "watch:css": "nodemon -e src/scss -x \"npm run build:css\"",
+    "watch:examples": "examples/buildAll node_modules/.bin/watchify & npm run watch:js",
+    "watch:js": "nodemon --watch src -e js --ignore src/scss -x \"npm run build:lib\""
   },
   "repository": {
     "type": "git",

+ 0 - 1
plugins.js

@@ -1 +0,0 @@
-module.exports = require('./lib/plugins')

+ 0 - 8
src/create.js

@@ -1,8 +0,0 @@
-import Core from './core'
-
-/**
- * Factory function for creating a new
- * instance of the core.
- * @returns { object } new Core instance
- */
-export default () => new Core()

+ 5 - 10
src/index.js

@@ -1,12 +1,7 @@
 import Core from './core'
-import {
-  DragDrop,
-  TransloaditBasic,
-  Tus10
-} from './plugins'
+import plugins from './plugins'
 
-import createUppy from './create'
-
-var uppy = createUppy();
-
-export default uppy
+export default {
+  Core,
+  plugins
+}

+ 0 - 0
build/.empty → src/scss/index.scss