Explorar o código

switched up the build process a bit more, so most of the build occurs in-place, meaning the src and dest options are the same. This allows us to simple copy everthing at once and not need to specify all the edge cases like I did previously in copy:everything_left_in_src

Spencer Alger %!s(int64=12) %!d(string=hai) anos
pai
achega
3b14e3e226
Modificáronse 2 ficheiros con 42 adicións e 50 borrados
  1. 42 50
      Gruntfile.js
  2. 0 0
      src/app/panels/bettermap/leaflet.amd.js

+ 42 - 50
Gruntfile.js

@@ -18,42 +18,17 @@ module.exports = function (grunt) {
       on_start: ['<%= destDir %>', '<%= tempDir %>'],
       on_start: ['<%= destDir %>', '<%= tempDir %>'],
       temp: ['<%= tempDir %>'],
       temp: ['<%= tempDir %>'],
     },
     },
-    copy: {
-      everthing_left_in_src: {
-        cwd: '<%= srcDir %>',
-        expand: true,
-        src: [
-          '**/*.js',
-          '**/*.json',
-          'font/**/*',
-          'img/**/*',
-          'app/panels/bettermap/leaflet/images/*'
-        ],
-        dest: '<%= tempDir %>'
-      }
-    },
-    jshint: {
-      // just lint the source dir
-      source: {
-        files: {
-          src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js']
-        }
-      },
-      options: {
-        jshintrc: '.jshintrc'
-      }
-    },
     less: {
     less: {
+      // this is the only task, other than copy, that runs on the src directory, since we don't really need
+      // the less files in the dist. Everything else runs from on temp, and require copys everything
+      // from temp -> dist
       dist:{
       dist:{
-        options:{
-          compress: true
-        },
         expand: true,
         expand: true,
         cwd:'<%= srcDir %>/vendor/bootstrap/less/',
         cwd:'<%= srcDir %>/vendor/bootstrap/less/',
         src: ['bootstrap.dark.less', 'bootstrap.light.less'],
         src: ['bootstrap.dark.less', 'bootstrap.light.less'],
         dest: '<%= tempDir %>/css/',
         dest: '<%= tempDir %>/css/',
       },
       },
-      // Compile to src when not building
+      // Compile in place when not building
       src:{
       src:{
         options: {
         options: {
           paths: ["<%= srcDir %>/vendor/bootstrap/less"],
           paths: ["<%= srcDir %>/vendor/bootstrap/less"],
@@ -65,24 +40,34 @@ module.exports = function (grunt) {
         }
         }
       }
       }
     },
     },
-    cssmin: {
-      dist: {
-        expand: true,
+    copy: {
+      // copy source to temp, we will minify in place for the dist build
+      everything_but_less_to_temp: {
         cwd: '<%= srcDir %>',
         cwd: '<%= srcDir %>',
-        src: [
-          '**/*.css'
-        ],
+        expand: true,
+        src: ['**/*', '!**/*.less'],
         dest: '<%= tempDir %>'
         dest: '<%= tempDir %>'
       }
       }
     },
     },
+    jshint: {
+      // just lint the source dir
+      source: {
+        files: {
+          src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js']
+        }
+      },
+      options: {
+        jshintrc: '.jshintrc'
+      }
+    },
     htmlmin:{
     htmlmin:{
-      dist: {
+      build: {
         options:{
         options:{
           removeComments: true,
           removeComments: true,
           collapseWhitespace: true
           collapseWhitespace: true
         },
         },
         expand: true,
         expand: true,
-        cwd: '<%= srcDir %>',
+        cwd: '<%= tempDir %>',
         src: [
         src: [
           'index.html',
           'index.html',
           'app/panels/**/*.html',
           'app/panels/**/*.html',
@@ -91,8 +76,16 @@ module.exports = function (grunt) {
         dest: '<%= tempDir %>'
         dest: '<%= tempDir %>'
       }
       }
     },
     },
+    cssmin: {
+      build: {
+        expand: true,
+        cwd: '<%= tempDir %>',
+        src: '**/*.css',
+        dest: '<%= tempDir %>'
+      }
+    },
     ngmin: {
     ngmin: {
-      scripts: {
+      build: {
         expand:true,
         expand:true,
         cwd:'<%= tempDir %>',
         cwd:'<%= tempDir %>',
         src: [
         src: [
@@ -109,7 +102,7 @@ module.exports = function (grunt) {
       }
       }
     },
     },
     requirejs: {
     requirejs: {
-      compile_temp: {
+      build: {
         options: {
         options: {
           appDir: '<%= tempDir %>',
           appDir: '<%= tempDir %>',
           dir: '<%= destDir %>',
           dir: '<%= destDir %>',
@@ -119,14 +112,13 @@ module.exports = function (grunt) {
 
 
           optimize: 'none',
           optimize: 'none',
           optimizeCss: 'none',
           optimizeCss: 'none',
+          optimizeAllPluginResources: false,
 
 
           removeCombined: true,
           removeCombined: true,
-          preserveLicenseComments: false,
           findNestedDependencies: true,
           findNestedDependencies: true,
-          normalizeDirDefines: "none",
+          normalizeDirDefines: 'all',
           inlineText: true,
           inlineText: true,
           skipPragmas: true,
           skipPragmas: true,
-          optimizeAllPluginResources: false,
 
 
           done: function (done, output) {
           done: function (done, output) {
             var duplicates = require('rjs-build-analysis').duplicates(output);
             var duplicates = require('rjs-build-analysis').duplicates(output);
@@ -175,7 +167,7 @@ module.exports = function (grunt) {
           },
           },
           {
           {
             expand: true,
             expand: true,
-            src: ['LICENSE.md','README.md'],
+            src: ['LICENSE.md', 'README.md'],
             dest: '<%= pkg.name %>-latest'
             dest: '<%= pkg.name %>-latest'
           }
           }
         ]
         ]
@@ -193,7 +185,7 @@ module.exports = function (grunt) {
           },
           },
           {
           {
             expand: true,
             expand: true,
-            src: ['LICENSE.md','README.md'],
+            src: ['LICENSE.md', 'README.md'],
             dest: '<%= pkg.name %>-latest'
             dest: '<%= pkg.name %>-latest'
           }
           }
         ]
         ]
@@ -219,7 +211,7 @@ module.exports = function (grunt) {
   };
   };
 
 
   // setup the modules require will build
   // setup the modules require will build
-  var requireModules = config.requirejs.compile_temp.options.modules = [
+  var requireModules = config.requirejs.build.options.modules = [
     {
     {
       // main/common module
       // main/common module
       name: 'app',
       name: 'app',
@@ -271,12 +263,12 @@ module.exports = function (grunt) {
   grunt.registerTask('build', [
   grunt.registerTask('build', [
     'jshint:source',
     'jshint:source',
     'clean:on_start',
     'clean:on_start',
-    'htmlmin',
     'less:dist',
     'less:dist',
-    'cssmin',
-    'copy:everthing_left_in_src',
-    'ngmin',
-    'requirejs:compile_temp',
+    'copy:everything_but_less_to_temp',
+    'htmlmin:build',
+    'cssmin:build',
+    'ngmin:build',
+    'requirejs:build',
     'clean:temp',
     'clean:temp',
     'build:write_revision',
     'build:write_revision',
     'uglify:dest'
     'uglify:dest'

+ 0 - 0
src/app/panels/bettermap/leaflet.amd.js