gdg-x / hoverboard

Conference website template
https://hoverboard-master.web.app
Other
1.11k stars 1.09k forks source link

Auto selection of window.ENV variable #251

Closed davinkevin closed 6 years ago

davinkevin commented 7 years ago

Hi,

We are working with this template and we don't find a way to change the window.ENV without hard-coding it.

Do you plan to handle this feature ? For now, in our project, we add this kind of code as a quick and dirty way to support it :

    window.ENV = function(hostmane) {

      if (
        hostmane === '2017.devfesttoulouse.fr' ||
        hostmane === 'devfesttoulouse-c76d7.firebaseapp.com'
      ) {
        return 'prod';
      }

      return 'dev';
    }(window.location.hostname);

But I think this is something which should be done during build phase depending of the travis CI env value.

If you are interested about a PR about that, let me know ;)

Linked to https://github.com/GDGToulouse/site-devfest-toulouse-2017/issues/8

ozasadnyy commented 7 years ago

Hi, you can change ENV here: https://github.com/gdg-x/hoverboard/blob/master/index.html#L91

davinkevin commented 7 years ago

Yeah, but i'm looking for a solution without hard coding it.

From my point of view, this value should be defined to "dev" in source code, but should be change during build operation depending of environment variable. For example, we can detect if the build process is executing in Travis or CI environment and choose to replace dev by prod.

ozasadnyy commented 7 years ago

In this case, you have to pass this variable to gulp task and merge with config variable before nunjucks will compile the files https://github.com/gdg-x/hoverboard/blob/master/gulpfile.js#L54

ozasadnyy commented 6 years ago

Now you can do it with https://github.com/gdg-x/hoverboard/tree/hoverboard-v2/config and running proper script https://github.com/gdg-x/hoverboard/blob/hoverboard-v2/package.json#L16