Choice of different environments in yo angular fullstack projects from grunts?

In a scaffold project using yo angular fullstack, I usually run the application using grunt using grunt (I'm not an expert on it).

Example

grunt 

grunt serve

etc.

As far as I know, I have three different environments (development, testing, production). Every time I need to change, I need to go to the main file by changing the correct line ("Development" by default).

How to choose one of them from the terminal? I am absolutely sure that there must be a way to do this from grunts ...

I can imagine that it should be something like

grunt serve --env:prod

grunt serve --test

grunt serve development

I tried all of them, but nothing, I spent some time trying to figure it out from the Grunt file, but I can not find any googling.

Does anyone know how to do this? Any help would be appreciated

+4
2

NODE_ENV=production grunt, - . ,

> export NODE_ENV=production
> grunt

, .

+1

serve. . , .

grunt serve

()

grunt serve:dist

Debug

grunt serve:debug

, Grunt .

serve

grunt.registerTask('serve', function (target) {
  if (target === 'dist') {
    return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'wait', 'open', 'express-keepalive']);
  }

  if (target === 'debug') {
    return grunt.task.run([
      'clean:server',
      'env:all',<% if(filters.stylus) { %>
      'injector:stylus', <% } %><% if(filters.less) { %>
      'injector:less', <% } %><% if(filters.sass) { %>
      'injector:sass', <% } %>
      'concurrent:server',
      'injector',
      'wiredep',
      'autoprefixer',
      'concurrent:debug'
    ]);
  }

  grunt.task.run([
    'clean:server',
    'env:all',<% if(filters.stylus) { %>
    'injector:stylus', <% } %><% if(filters.less) { %>
    'injector:less', <% } %><% if(filters.sass) { %>
    'injector:sass', <% } %>
    'concurrent:server',
    'injector',
    'wiredep',
    'autoprefixer',
    'express:dev',
    'wait',
    'open',
    'watch'
  ]);
});
+1

Source: https://habr.com/ru/post/1584200/


All Articles