guzart / gulp-ng-constant

Gulp plugin for dynamic generation of angular constant modules.
MIT License
109 stars 26 forks source link

Adding an object constant #20

Closed MarkAPhillips closed 9 years ago

MarkAPhillips commented 9 years ago

Hi can you advise if it is possible to add object constants and the best practice for adding these . This technique tends to be used for injecting third party objects that are assigned to the global.

e.g.

.constants("moment",moment)

If I try this in gulp I get a reference error moment is undefined. I can add this manually and have no issues and works as expected but would like to add as part of the build process if possible. Thanks

MarkAPhillips commented 9 years ago

I found a work around by doing the following:

wrap: "(function(){'use strict';\n\n<%= __ngModule.replace(';','.constant\(\"moment\",moment\);') %>}();",

Works but nice to see if there are any alternative out there.I basically replace the content in the wrap option.