Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Commit

Permalink
feat(CommonJS): more elegant importing of JS/CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
rnicholus committed May 6, 2016
1 parent 7d2dea3 commit 95fc444
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = function(grunt) {
path = require("path");
pkg = require("./package.json");
paths = {
commonJs: "./lib/commonJs",
dist: path.join("./_dist", pkg.version),
build: "./_build",
src: "./client",
Expand Down
3 changes: 3 additions & 0 deletions lib/commonJs/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../all.fine-uploader/all.fine-uploader");
3 changes: 3 additions & 0 deletions lib/commonJs/azure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../azure.fine-uploader/azure.fine-uploader");
3 changes: 3 additions & 0 deletions lib/commonJs/jquery/azure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../azure.jquery.fine-uploader/azure.jquery.fine-uploader");
3 changes: 3 additions & 0 deletions lib/commonJs/jquery/s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../s3.jquery.fine-uploader/s3.jquery.fine-uploader");
3 changes: 3 additions & 0 deletions lib/commonJs/jquery/traditional.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../../jquery.fine-uploader/jquery.fine-uploader");
3 changes: 3 additions & 0 deletions lib/commonJs/s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../s3.fine-uploader/s3.fine-uploader");
3 changes: 3 additions & 0 deletions lib/commonJs/traditional.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

module.exports = require("../fine-uploader/fine-uploader");
30 changes: 29 additions & 1 deletion lib/grunt/tasks/release.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
/* jshint node: true */
var path = require("path"),
npm = require("npm"),
fs = require("fs");
fs = require("fs"),
fsSync = require("fs-sync"),

makeCommonJsLibDir = function(paths) {
// copy all files from all.fine-uploader dir into lib
fsSync.copy(path.join(paths.dist, "all.fine-uploader"), path.join(paths.dist, "lib"));

// delete all the JS files & .min.css files
var libFiles = fs.readdirSync(path.join(paths.dist, "lib")),
index
for (index in libFiles) {
if (path.extname(libFiles[index]) === ".js") {
fsSync.remove(path.join(paths.dist, "lib", libFiles[index]));
}
else if (libFiles[index].endsWith(".min.css")) {
fsSync.remove(path.join(paths.dist, "lib", libFiles[index]));
}
}

// remove redundancies in css filenames
fs.renameSync(path.join(paths.dist, "lib/fine-uploader.css"), path.join(paths.dist, "lib/legacy.css"))
fs.renameSync(path.join(paths.dist, "lib/fine-uploader-gallery.css"), path.join(paths.dist, "lib/gallery.css"))
fs.renameSync(path.join(paths.dist, "lib/fine-uploader-new.css"), path.join(paths.dist, "lib/new.css"))

// copy over the CommonJS index files
fsSync.copy(path.join(paths.commonJs), path.join(paths.dist, "lib"));
}

module.exports = function(grunt) {
"use strict";
Expand Down Expand Up @@ -52,6 +78,8 @@ module.exports = function(grunt) {
delete pkgJsonCopy[k];
});

makeCommonJsLibDir(paths);

fs.writeFileSync(path.join(paths.dist, "package.json"), JSON.stringify(pkgJsonCopy, null, 2));
fs.writeFileSync(path.join(paths.dist, ".npmignore"), npmIgnore);
fs.writeFileSync(path.join(paths.dist, "README.md"), readme);
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "fine-uploader",
"title": "Fine Uploader",
"main": "lib/traditional.js",
"version": "5.8.0",
"description": "Multiple file upload component with progress-bar, drag-and-drop, support for all modern browsers.",
"directories": {
Expand Down Expand Up @@ -53,10 +54,11 @@
},
"devDependencies": {
"async": "0.2.9",
"fs-sync": "1.0.2",
"glob": "3.2.6",
"grunt": "^0.4.5",
"grunt-aws-s3": "^0.10.0",
"grunt-banner": "0.6.0",
"grunt-banner": "0.2.0",
"grunt-contrib-clean": "0.4.1",
"grunt-contrib-compress": "0.5.2",
"grunt-contrib-concat": "0.3.0",
Expand Down

0 comments on commit 95fc444

Please sign in to comment.