Nils Schneider 9 jaren geleden
bovenliggende
commit
bfe6fe346d
8 gewijzigde bestanden met toevoegingen van 189 en 1 verwijderingen
  1. 2 1
      .gitignore
  2. 10 0
      Gruntfile.js
  3. 15 0
      html/index.html
  4. 18 0
      package.json
  5. 65 0
      tasks/build.js
  6. 11 0
      tasks/clean.js
  7. 33 0
      tasks/development.js
  8. 35 0
      tasks/linting.js

+ 2 - 1
.gitignore

@@ -1,2 +1,3 @@
 bower_components/
-app-combined.js
+node_modules/
+build/

+ 10 - 0
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"])
+}
+

+ 15 - 0
html/index.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, user-scalable=no">
+    <link rel="stylesheet" href="css/ionicons.min.css">
+    <link rel="stylesheet" href="roboto-slab-fontface.css">
+    <link rel="stylesheet" href="style.css">
+    <script src="vendor/es6-shim/es6-shim.min.js"></script>
+    <script src="vendor/intl/Intl.complete.js"></script>
+    <script src="app.js"></script>
+  </head>
+  <body>
+  </body>
+</html>

+ 18 - 0
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"
+  }
+}

+ 65 - 0
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')
+}

+ 11 - 0
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")
+}

+ 33 - 0
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")
+}

+ 35 - 0
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")
+}