5

I am using a bunch of "console.log" calls for debugging my JS application. However, I'd like to remove these automatically when sending the code to production.

Using a traditional gulpfile, I would use the "gulp-strip-debug" plugin that will be only triggered when I run the "production" main task.

When using Laravel Elixir, though, it's a little bit different. I use the "--production" flag to minimize my assets, but I'd like to execute the strip-debug task afterwards. I could not find how to do that in the Laravel 5.1 documentation.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
kant312
  • 1,114
  • 1
  • 15
  • 28

1 Answers1

6

After checking the elixir.config object, it seems that the --production flag sets the elixir.config.production variable to true.

It is therefore possible to wrap the execution of a specific task in an if(elixir.config.production) statement, allowing you to trigger them when the environment is "production" or if you manually specified it by using the --production flag from the command line.

kant312
  • 1,114
  • 1
  • 15
  • 28