Bläddra i källkod

Playground fixes

Kevin van Zonneveld 9 år sedan
förälder
incheckning
2c8930c706

+ 2 - 0
.gitignore

@@ -4,3 +4,5 @@ build/
 npm-debug.log
 examples/playground/static/js/app.js
 examples/playground/static/transloadit-js-client/
+
+examples/playground/static/js/app.js

+ 28 - 11
bin/builder

@@ -1,9 +1,12 @@
 #!/bin/bash
-TRANSFORMS="[ babelify ]"
-tool="${1:-node_modules/.bin/browserify}"
-toolBasename="$(basename "${tool}")"
 
-if [ "${toolBasename}" = "node-sass" ]; then
+# Setup
+#######################################################
+transformations="[ babelify ]"
+toolpath="${1:-node_modules/.bin/browserify}"
+toolname="$(basename "${toolpath}")"
+
+if [ "${toolname}" = "node-sass" ]; then
   srcExtension="scss"
   dstExtension="css"
 else
@@ -11,26 +14,40 @@ else
   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/transloadit-js-client.${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 watchify
-  if [ "${toolBasename}" = "node-sass" ]; then
-    "${tool}" "${src}" "${dst}"
+  # Argument should be `browserify`, or `node-sass`
+  if [ "${toolname}" = "node-sass" ]; then
+    "${toolpath}" "${src}" "${dst}" ${extraArgs}
   else
-    "${tool}" "${src}" -o "${dst}" -t ${TRANSFORMS}
+    "${toolpath}" "${src}" -o "${dst}" ${extraArgs}
   fi
 done
 
 # All files in one bundle
-if [ "${toolBasename}" = "node-sass" ]; then
-  "${tool}" ${allSourceFiles} "build/transloadit-bundle.${dstExtension}"
+#######################################################
+echo "--> *.${srcExtension} -> ${bundleTarget}"
+if [ "${toolname}" = "node-sass" ]; then
+  "${toolpath}" ${allSourceFiles} "${bundleTarget}" ${extraArgs}
 else
-  "${tool}" ${allSourceFiles} -o "build/transloadit-bundle.${dstExtension}" -t ${TRANSFORMS}
+  "${toolpath}" ${allSourceFiles} -o "${bundleTarget}" ${extraArgs}
 fi
 
 # Install into examples

+ 3 - 3
bs-config.js

@@ -18,14 +18,14 @@ module.exports = {
             "port": 8080
         }
     },
-    "files": ["build/*.css", "build/*.js", "build/index.html"],
-    "index": "build/index.html",
+    "files": [ "examples/playground/*"],
+    "index": "index.html",
     "watchOptions": {},
     "server": true,
     "proxy": false,
     "port": 3000,
     "middleware": false,
-    "serveStatic": ["build"],
+    "serveStatic": ["examples/playground"],
     "ghostMode": {
         "clicks": true,
         "scroll": true,

+ 1 - 1
examples/buildAll

@@ -5,4 +5,4 @@ OUTPUT=examples/playground/static/js/app.js
 TRANSFORMS="[ babelify ]"
 
 # Argument should be browserify or watchify
-$ENTRY -o $OUTPUT -t $TRANSFORMS
+$1 $ENTRY -o $OUTPUT -t $TRANSFORMS

+ 2 - 2
examples/playground/index.html

@@ -65,12 +65,12 @@
 </body>
 
 <!-- Include the built js client -->
-<script src="static/js/transloadit-js-client.js"></script>
+<script src="static/transloadit-js-client/transloadit-js-client.js"></script>
 <script src="static/js/app.js"></script>
 
 <!-- Apply the js client on a selector -->
 <script>
-  var tl = Transloadit("#upload-target");
+  // var tl = Transloadit("#upload-target");
 </script>
 
 <!-- Add the branch name to the <title> and <h1> of this page -->

+ 3 - 3
examples/playground/src/js/app.js

@@ -1,6 +1,6 @@
-import Transloadit from '../../../src/js/core/Transloadit';
-import DragDrop from '../../../src/js/plugins/DragDrop';
-import Tus10 from '../../../src/js/plugins/Tus10';
+// import Transloadit from '../../../src/js/core/Transloadit';
+// import DragDrop from '../../../src/js/plugins/DragDrop';
+// import Tus10 from '../../../src/js/plugins/Tus10';
 
 const transloadit = new Transloadit({wait: false});
 const files = transloadit

+ 0 - 0
examples/playground/static/js/app.js