diff --git a/.gitignore b/.gitignore index bda82cb9b..0ccd25529 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ pom.xml .repl .nrepl-port /hicv/ +/dist/ node_modules /resources/public/css /resources/public/js diff --git a/gulpfile.js b/gulpfile.js index 63b527d96..f161fda34 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,37 +1,58 @@ // Main Gulp var gulp = require("gulp"); - +var runseq = require('run-sequence'); var clean = require("gulp-clean"); var scss = require("gulp-sass"); var plumber = require("gulp-plumber"); var autoprefixer = require('gulp-autoprefixer'); var watch = require("gulp-watch"); +var cssmin = require("gulp-cssmin"); // Paths var paths = {}; -paths.app = "resources/public/"; -paths.dist = "resources/public/"; - +paths.app = "./resources/"; +paths.output = "./resources/public/"; +paths.dist = "./dist"; paths.scss = paths.app + "styles/**/*.scss"; -gulp.task("scss", function () { +gulp.task("scss", function() { return gulp.src(paths.app + "styles/main.scss") - .pipe(plumber()) - .pipe(scss({ style: "expanded" })) - .pipe(gulp.dest(paths.dist + "css/")); + .pipe(plumber()) + .pipe(scss({ style: "expanded" })) + .pipe(gulp.dest(paths.output + "css/")); }); -gulp.task("autoprefixer", ["scss"], function () { - return gulp.src(paths.dist + "css/main.css") - .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) - .pipe(gulp.dest(paths.dist + "css/")); +gulp.task("autoprefixer", function() { + return gulp.src(paths.output + "css/main.css") + .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) + .pipe(gulp.dest(paths.output + "css/")); }); +gulp.task("cssmin", function() { + return gulp.src(paths.output + "css/main.css") + .pipe(cssmin()) + .pipe(gulp.dest(paths.output + "css/")); +}); + +gulp.task("styles:dev", function(next) { + runseq("scss", "autoprefixer", next); +}); + +gulp.task("styles:dist", function(next) { + runseq("scss", "autoprefixer", next); +}); + +gulp.task("copy", function() { + return gulp.src(paths.output + "/**/*.*") + .pipe(gulp.dest(paths.dist)); +}); // Default -gulp.task("dist", ["autoprefixer"]); +gulp.task("dist", function(next) { + runseq("styles:dist", "cssmin", "copy", next); +}); // Watch -gulp.task("default", ["dist"], function () { +gulp.task("default", ["styles:dev"], function () { gulp.watch(paths.scss, ["autoprefixer"]); }); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index dd2757918..50fc0b20b 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -209,6 +209,23 @@ "from": "chokidar@>=1.0.3 <2.0.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.4.2.tgz" }, + "clean-css": { + "version": "3.4.9", + "from": "clean-css@>=3.1.9 <4.0.0", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.9.tgz", + "dependencies": { + "commander": { + "version": "2.8.1", + "from": "commander@>=2.8.0 <2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz" + }, + "source-map": { + "version": "0.4.4", + "from": "source-map@>=0.4.0 <0.5.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz" + } + } + }, "cliui": { "version": "3.1.0", "from": "cliui@>=3.0.3 <4.0.0", @@ -415,6 +432,11 @@ "from": "filename-regex@>=2.0.0 <3.0.0", "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz" }, + "filesize": { + "version": "2.0.4", + "from": "filesize@>=2.0.0 <2.1.0", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-2.0.4.tgz" + }, "fill-range": { "version": "2.2.3", "from": "fill-range@>=2.1.0 <3.0.0", @@ -705,11 +727,113 @@ } } }, + "gulp-cssmin": { + "version": "0.1.7", + "from": "gulp-cssmin@latest", + "resolved": "https://registry.npmjs.org/gulp-cssmin/-/gulp-cssmin-0.1.7.tgz", + "dependencies": { + "ansi-regex": { + "version": "0.2.1", + "from": "ansi-regex@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz" + }, + "ansi-styles": { + "version": "1.1.0", + "from": "ansi-styles@>=1.1.0 <2.0.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz" + }, + "chalk": { + "version": "0.5.1", + "from": "chalk@>=0.5.0 <0.6.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz" + }, + "graceful-fs": { + "version": "2.0.3", + "from": "graceful-fs@>=2.0.0 <2.1.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz" + }, + "gulp-util": { + "version": "2.2.20", + "from": "gulp-util@>=2.2.0 <2.3.0", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz" + }, + "has-ansi": { + "version": "0.1.0", + "from": "has-ansi@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz" + }, + "lodash._reinterpolate": { + "version": "2.4.1", + "from": "lodash._reinterpolate@>=2.4.1 <3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz" + }, + "lodash.escape": { + "version": "2.4.1", + "from": "lodash.escape@>=2.4.1 <2.5.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz" + }, + "lodash.keys": { + "version": "2.4.1", + "from": "lodash.keys@>=2.4.1 <2.5.0", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz" + }, + "lodash.template": { + "version": "2.4.1", + "from": "lodash.template@>=2.4.1 <3.0.0", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz" + }, + "lodash.templatesettings": { + "version": "2.4.1", + "from": "lodash.templatesettings@>=2.4.1 <2.5.0", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz" + }, + "minimist": { + "version": "0.2.0", + "from": "minimist@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.0.tgz" + }, + "readable-stream": { + "version": "1.0.33", + "from": "readable-stream@>=1.0.17 <1.1.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz" + }, + "strip-ansi": { + "version": "0.3.0", + "from": "strip-ansi@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz" + }, + "supports-color": { + "version": "0.2.0", + "from": "supports-color@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz" + }, + "through2": { + "version": "0.5.1", + "from": "through2@>=0.5.0 <0.6.0", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz" + }, + "vinyl": { + "version": "0.2.3", + "from": "vinyl@>=0.2.1 <0.3.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz" + }, + "xtend": { + "version": "3.0.0", + "from": "xtend@>=3.0.0 <3.1.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz" + } + } + }, "gulp-plumber": { "version": "1.1.0", "from": "gulp-plumber@1.1.0", "resolved": "https://registry.npmjs.org/gulp-plumber/-/gulp-plumber-1.1.0.tgz" }, + "gulp-rename": { + "version": "1.1.0", + "from": "gulp-rename@>=1.1.0 <1.2.0", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz" + }, "gulp-sass": { "version": "2.2.0", "from": "gulp-sass@2.2.0", @@ -1185,6 +1309,11 @@ "from": "map-obj@>=1.0.1 <2.0.0", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz" }, + "map-stream": { + "version": "0.0.4", + "from": "map-stream@0.0.4", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.4.tgz" + }, "meow": { "version": "3.7.0", "from": "meow@>=3.3.0 <4.0.0", @@ -1581,6 +1710,11 @@ } } }, + "run-sequence": { + "version": "1.1.5", + "from": "run-sequence@latest", + "resolved": "https://registry.npmjs.org/run-sequence/-/run-sequence-1.1.5.tgz" + }, "sass-graph": { "version": "2.1.1", "from": "sass-graph@>=2.0.1 <3.0.0", @@ -1718,6 +1852,22 @@ "from": "tar@>=2.0.0 <3.0.0", "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz" }, + "temp-write": { + "version": "0.1.1", + "from": "temp-write@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/temp-write/-/temp-write-0.1.1.tgz", + "dependencies": { + "graceful-fs": { + "version": "2.0.3", + "from": "graceful-fs@>=2.0.0 <2.1.0" + } + } + }, + "tempfile": { + "version": "0.1.3", + "from": "tempfile@>=0.1.2 <0.2.0", + "resolved": "https://registry.npmjs.org/tempfile/-/tempfile-0.1.3.tgz" + }, "through2": { "version": "2.0.1", "from": "through2@>=2.0.0 <3.0.0", @@ -1785,6 +1935,11 @@ "from": "util-deprecate@>=1.0.1 <1.1.0", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" }, + "uuid": { + "version": "1.4.2", + "from": "uuid@>=1.4.0 <1.5.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-1.4.2.tgz" + }, "v8flags": { "version": "2.0.11", "from": "v8flags@>=2.0.2 <3.0.0", diff --git a/package.json b/package.json index 04078e06b..7eb06fc8e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "scripts": { "watch": "gulp", - "dist": "gulp dist", + "dist": "./scripts/dist && gulp dist", "figwheel": "./scripts/figwheel", "test-watch": "./scripts/watch", "test-build": "./scripts/build", @@ -17,11 +17,13 @@ }, "devDependencies": { "gulp": "3.9.1", + "gulp-autoprefixer": "3.1.0", "gulp-clean": "0.3.1", + "gulp-cssmin": "0.1.7", "gulp-plumber": "1.1.0", "gulp-sass": "2.2.0", - "gulp-autoprefixer": "3.1.0", - "gulp-watch": "4.3.5" + "gulp-watch": "4.3.5", + "run-sequence": "1.1.5" }, "dependencies": { "source-map-support": "0.4.0" diff --git a/scripts/dist b/scripts/dist new file mode 100755 index 000000000..3b937ba65 --- /dev/null +++ b/scripts/dist @@ -0,0 +1,2 @@ +#!/bin/sh +lein trampoline run -m clojure.main scripts/dist.clj diff --git a/scripts/dist.clj b/scripts/dist.clj new file mode 100644 index 000000000..2f8ab09ed --- /dev/null +++ b/scripts/dist.clj @@ -0,0 +1,21 @@ +(require '[cljs.build.api :as b] + '[cljs.tagged-literals]) + +(alter-var-root #'cljs.tagged-literals/*cljs-data-readers* + assoc 'ux/tr (fn [v] `(uxbox.locales/tr ~v))) + +(println "Building ...") + +(let [start (System/nanoTime)] + (b/build + (b/inputs "src") + {:main 'uxbox.core + :parallel-build false + :warnings {:ns-var-clash false} + :output-to "resources/public/js/main.js" + :output-dir "resources/public/js" + :optimizations :simple + :language-in :ecmascript5 + :language-out :ecmascript5 + :verbose true}) + (println "... done. Elapsed" (/ (- (System/nanoTime) start) 1e9) "seconds"))