Git Product home page Git Product logo

Comments (3)

mlegenhausen avatar mlegenhausen commented on June 2, 2024

Could you provide the rest of your grunt configuration cause guessing about why concat is not working only by seeing the ngconstant configuration is really hard.

Some guesses. Maybe you should check the order of the grunt tasks and make sure that your concat task picks up the file from .tmp.

from grunt-ng-constant.

markalanevans avatar markalanevans commented on June 2, 2024

Here is my gruntfile.js

"use strict";
var LIVERELOAD_PORT, lrSnippet, mountFolder;

LIVERELOAD_PORT = 35728;

lrSnippet = require("connect-livereload")({
  port: LIVERELOAD_PORT
});

var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;

mountFolder = function(connect, dir) {
  return connect["static"](require("path").resolve(dir));
};

module.exports = function(grunt) {
  var yeomanConfig;
  require("load-grunt-tasks")(grunt);
  require("time-grunt")(grunt);
  yeomanConfig = {
    app: "client",
    dist: "../public"
  };
  try {
    yeomanConfig.app = require("./bower.json").appPath || yeomanConfig.app;
  } catch (_error) {}
  grunt.initConfig({
    yeoman: yeomanConfig,
    watch: {
      compass: {
        files: ["<%= yeoman.app %>/styles/**/*.{scss,sass}"],
        tasks: ["compass:server"]
      },
      less: {
        files: ["<%= yeoman.app %>/styles-less/**/*.less"],
        tasks: ["less:server"]
      },
      livereload: {
        options: {
          livereload: LIVERELOAD_PORT
        },
        files: ["<%= yeoman.app %>/index.html", "<%= yeoman.app %>/views/**/*.html", "<%= yeoman.app %>/styles/**/*.scss", "<%= yeoman.app %>/styles-less/**/*.less", ".tmp/styles/**/*.css", "{.tmp,<%= yeoman.app %>}/scripts/**/*.js", "{.tmp,<%= yeoman.app %>}/scripts/**/*.html","<%= yeoman.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}"]
      }
    },
    ngconstant: {
      options:{
        name: 'sgApp',
        deps:false
      },
      dist: {
        options:{
          dest: "client/scripts/global/config.js",
        },

        constants: "client/config/dist.config.json"
      },
      server: {
        options: {
          dest: ".tmp/scripts/global/config.js",
          values: {
            debug: true
          }
        },

        constants: "client/config/server.config.json"
      }
    },
    connect: {
      options: {
        port: 9000,
        hostname: "localhost"
      },
      proxies: [{
        context: '/api',
        host: 'dashboard.local.shopgeniusapp.com',
        port: 80,
        https: false,
        changeOrigin: true,
        rewrite: {
          '^/api': ''
        }
      }],
      livereload: {
        options: {
          middleware: function(connect) {
            return [proxySnippet,lrSnippet, mountFolder(connect, ".tmp"), mountFolder(connect, yeomanConfig.app)];
          }
        }
      },
      test: {
        options: {
          middleware: function(connect) {
            return [mountFolder(connect, ".tmp"), mountFolder(connect, "test")];
          }
        }
      },
      dist: {
        options: {
          middleware: function(connect) {
            return [mountFolder(connect, yeomanConfig.dist)];
          }
        }
      }
    },
    open: {
      server: {
        url: "http://localhost:<%= connect.options.port %>"
      }
    },
    clean: {
      options: {
        force: true
      },
      dist: {
        files: [
          {
            dot: true,
            src: [".tmp", "<%= yeoman.dist %>/*", "!<%= yeoman.dist %>/.git*"]
          }
        ]
      },
      server: ".tmp"
    },
    jshint: {
      options: {
        jshintrc: ".jshintrc"
      },
      all: ["Gruntfile.js", "<%= yeoman.app %>/scripts/**/*.js"]
    },
    compass: {
      options: {
        sassDir: "<%= yeoman.app %>/styles",
        cssDir: ".tmp/styles",
        generatedImagesDir: ".tmp/styles/ui/images/",
        imagesDir: "<%= yeoman.app %>/styles/ui/images/",
        javascriptsDir: "<%= yeoman.app %>/scripts",
        fontsDir: "<%= yeoman.app %>/fonts",
        importPath: "<%= yeoman.app %>/bower_components",
        httpImagesPath: "styles/ui/images/",
        httpGeneratedImagesPath: "styles/ui/images/",
        httpFontsPath: "fonts",
        relativeAssets: true
      },
      dist: {
        options: {
          outputStyle: 'compressed',
          debugInfo: false,
          noLineComments: true
        }
      },
      server: {
        options: {
          debugInfo: true
        }
      },
      forvalidation: {
        options: {
          debugInfo: false,
          noLineComments: false
        }
      }
    },
    less: {
      server: {
        options: {
          strictMath: true,
          dumpLineNumbers: true,
          sourceMap: true,
          sourceMapRootpath: "",
          outputSourceFiles: true
        },
        files: [
          {
            expand: true,
            cwd: "<%= yeoman.app %>/styles-less",
            src: "main.less",
            dest: ".tmp/styles",
            ext: ".css"
          }
        ]
      },
      dist: {
        options: {
          cleancss: true,
          report: 'min'

        },
        files: [
          {
            expand: true,
            cwd: "<%= yeoman.app %>/styles-less",
            src: "main.less",
            dest: ".tmp/styles",
            ext: ".css"
          }
        ]
      }
    },
    coffee: {
      server: {
        options: {
          sourceMap: true,
          sourceRoot: ""
        },
        files: [
          {
            expand: true,
            cwd: "<%= yeoman.app %>/scripts",
            src: "**/*.coffee",
            dest: ".tmp/scripts",
            ext: ".js"
          }
        ]
      },
      dist: {
        options: {
          sourceMap: false,
          sourceRoot: ""
        },
        files: [
          {
            expand: true,
            cwd: "<%= yeoman.app %>/scripts",
            src: "**/*.coffee",
            dest: ".tmp/scripts",
            ext: ".js"
          }
        ]
      }
    },
    useminPrepare: {
      html: "<%= yeoman.app %>/index.html",
      options: {
        dest: "<%= yeoman.dist %>",
        flow: {
          steps: {
            js: ["concat"],
            css: ["cssmin"]
          },
          post: []
        }
      }
    },
    usemin: {
      html: ["<%= yeoman.dist %>/**/*.html", "!<%= yeoman.dist %>/bower_components/**"],
      css: ["<%= yeoman.dist %>/styles/**/*.css"],
      options: {
        dirs: ["<%= yeoman.dist %>"]
      }
    },
    htmlmin: {
      dist: {
        options: {},
        files: [
          {
            expand: true,
            cwd: "<%= yeoman.app %>",
            src: ["*.html", "views/*.html", "scripts/**/*.html"],
            dest: "<%= yeoman.dist %>"
          }
        ]
      }
    },
    copy: {
      dist: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: "<%= yeoman.app %>",
            dest: "<%= yeoman.dist %>",
            src: [
              "favicon.ico",
              "bower_components/font-awesome/css/*",
              "bower_components/font-awesome/fonts/*",
              "bower_components/weather-icons/css/*",
              "bower_components/weather-icons/font/*",
              "fonts/**/*",
              "i18n/**/*",
              "images/**/*",
              "styles/fonts/**/*",
              "styles/img/**/*",
              "styles/ui/images/*",
              "views/**/*",
              "scripts/**/*"
            ]
          }, {
            expand: true,
            cwd: ".tmp",
            dest: "<%= yeoman.dist %>",
            src: ["styles/**", "assets/**","scripts/**/*"]
          }, {
            expand: true,
            cwd: ".tmp/images",
            dest: "<%= yeoman.dist %>/images",
            src: ["generated/*"]
          }
        ]
      },
      styles: {
        expand: true,
        cwd: "<%= yeoman.app %>/styles",
        dest: ".tmp/styles/",
        src: "**/*.css"
      }
    },
    concurrent: {
      server: ["coffee:server", "compass:server", "copy:styles"],
      dist: ["coffee:dist", "compass:dist", "copy:styles", "htmlmin"],
      lessServer: ["coffee:server", "less:server", "copy:styles"],
      lessDist: ["coffee:dist", "less:dist", "copy:styles", "htmlmin"]
    },
    cssmin: {
      options: {
        keepSpecialComments: '0'
      },
      dist: {}
    },
    concat: {
      options: {
        separator: grunt.util.linefeed + ';' + grunt.util.linefeed
      },
      dist: {}
    },
    uglify: {
      options: {
        mangle: false,
        sourceMap:true,
        compress: {
          drop_console: true
        }
      },
      dist: {
        files: {
          "<%= yeoman.dist %>/scripts/app.js": [".tmp/**/*.js", "<%= yeoman.app %>/scripts/**/*.js"]
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-ng-constant');
  grunt.registerTask("server", function(target) {
    if (target === "dist") {
      return grunt.task.run(["build", "open", "connect:dist:keepalive"]);
    }

    return grunt.task.run(["clean:server", "concurrent:server", 'ngconstant:server','configureProxies:server', "connect:livereload", "open", "watch"]);
  });
  grunt.registerTask("lessServer", function(target) {
    if (target === "dist") {
      return grunt.task.run(["lessBuild", "open", "connect:dist:keepalive"]);
    }
    return grunt.task.run(["clean:server", "concurrent:lessServer", "connect:livereload", "open", "watch"]);
  });
  grunt.registerTask("build", ["clean:dist", "useminPrepare", "concurrent:dist", "ngconstant:dist", "copy:dist", "cssmin", "concat", "usemin"]);
  grunt.registerTask("lessBuild", ["clean:dist", "useminPrepare", "concurrent:lessDist", "copy:dist", "cssmin", "concat", "uglify", "usemin"]);
  return grunt.registerTask("default", ["server"]);
};

from grunt-ng-constant.

mlegenhausen avatar mlegenhausen commented on June 2, 2024

Ah ok you are using usemin a very powerful but error prone grunt task (my recommendation don't use it and try to build it with own building blocks).

Make sure that the generated concat configuration includes your config.js or it gets not concatinated. You should see the generated configuration in your console. If it is not you can add it by your self modifing the concat:generated task.

from grunt-ng-constant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.