diff --git a/.gitignore b/.gitignore index b68953f..949bb40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bower_components/ -app-combined.js +node_modules/ +build/ diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..fa4be60 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,10 @@ +"use strict" + +module.exports = function (grunt) { + grunt.loadTasks("tasks") + + grunt.registerTask("default", ["lint", "copy", "cssmin", "requirejs"]) + grunt.registerTask("lint", ["eslint"]) + grunt.registerTask("dev", ["default", "connect:server", "watch"]) +} + diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..cc12838 --- /dev/null +++ b/html/index.html @@ -0,0 +1,15 @@ + + +
+ + + + + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..ffb7085 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "meshviewer", + "scripts": { + "test": "node -e \"require('grunt').cli()\" '' clean lint" + }, + "devDependencies": { + "grunt": "^0.4.5", + "grunt-check-dependencies": "^0.6.0", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-connect": "^0.8.0", + "grunt-contrib-copy": "^0.5.0", + "grunt-contrib-cssmin": "^0.12.2", + "grunt-contrib-requirejs": "^0.4.4", + "grunt-contrib-uglify": "^0.5.1", + "grunt-contrib-watch": "^0.6.1", + "grunt-eslint": "^1.1.0" + } +} diff --git a/tasks/build.js b/tasks/build.js new file mode 100644 index 0000000..f91634c --- /dev/null +++ b/tasks/build.js @@ -0,0 +1,65 @@ +"use strict" + +module.exports = function(grunt) { + grunt.config.merge({ + copy: { + html: { + src: ["*.html"], + expand: true, + cwd: "html/", + dest: "build/" + }, + vendorjs: { + src: [ "es6-shim/es6-shim.min.js", + "intl/Intl.complete.js" + ], + expand: true, + cwd: "bower_components/", + dest: "build/vendor/" + }, + roboto: { + src: [ "fonts/*", + "roboto-slab-fontface.css" + ], + expand: true, + dest: "build/", + cwd: "bower_components/roboto-slab-fontface" + }, + ionicons: { + src: [ "fonts/*", + "css/ionicons.min.css" + ], + expand: true, + dest: "build/", + cwd: "bower_components/ionicons/", + } + }, + cssmin: { + target: { + files: { + "build/style.css": [ "bower_components/leaflet/dist/leaflet.css", + "bower_components/Leaflet.label/dist/leaflet.label.css", + "style.css" + ] + } + } + }, + requirejs: { + compile: { + options: { + baseUrl: "lib", + name: "../bower_components/almond/almond", + mainConfigFile: "app.js", + include: "../app", + wrap: true, + optimize: "uglify", + out: "build/app.js" + } + } + } + }) + + grunt.loadNpmTasks("grunt-contrib-copy") + grunt.loadNpmTasks("grunt-contrib-requirejs") + grunt.loadNpmTasks('grunt-contrib-cssmin') +} diff --git a/tasks/clean.js b/tasks/clean.js new file mode 100644 index 0000000..7e99509 --- /dev/null +++ b/tasks/clean.js @@ -0,0 +1,11 @@ +"use strict" + +module.exports = function (grunt) { + grunt.config.merge({ + clean: { + build: ["build/**/*", "node_modules/grunt-newer/.cache"] + } + }) + + grunt.loadNpmTasks("grunt-contrib-clean") +} diff --git a/tasks/development.js b/tasks/development.js new file mode 100644 index 0000000..30f3749 --- /dev/null +++ b/tasks/development.js @@ -0,0 +1,33 @@ +"use strict" + +module.exports = function (grunt) { + grunt.config.merge({ + connect: { + server: { + options: { + base: "build/", //TODO: once grunt-contrib-connect 0.9 is released, set index file + livereload: true + } + } + }, + watch: { + sources: { + options: { + livereload: true + }, + files: ["*.css", "app.js", "lib/*.js", "*.html"], + tasks: ["default"] + }, + config: { + options: { + reload: true + }, + files: ["Gruntfile.js", "tasks/*.js"], + tasks: [] + } + } + }) + + grunt.loadNpmTasks("grunt-contrib-connect") + grunt.loadNpmTasks("grunt-contrib-watch") +} diff --git a/tasks/linting.js b/tasks/linting.js new file mode 100644 index 0000000..2380155 --- /dev/null +++ b/tasks/linting.js @@ -0,0 +1,35 @@ +"use strict" + +module.exports = function (grunt) { + grunt.config.merge({ + checkDependencies: { + options: { + install: true + }, + bower: { + options: { + packageManager: "bower" + } + }, + npm: {} + }, + eslint: { + options: { + rule: { + semi: [2, "never"], + strict: [2, "never"], + curly: [2, "multi"] + } + }, + sources: { + src: ["app.js", "!Gruntfile.js", "lib/*.js"] + }, + grunt: { + src: ["Gruntfile.js", "tasks/*.js"] + } + } + }) + + grunt.loadNpmTasks("grunt-check-dependencies") + grunt.loadNpmTasks("grunt-eslint") +}