Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable a development / production mode flag #199

Open
1 of 5 tasks
thescientist13 opened this issue Sep 20, 2019 · 1 comment
Open
1 of 5 tasks

Enable a development / production mode flag #199

thescientist13 opened this issue Sep 20, 2019 · 1 comment
Labels
CLI feature New feature or request
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Sep 20, 2019

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

As might be the case with certain plugins are other parts of Greenwood's build pipeline, having a production flag that is set during the config lifecycle based on whether it is a develop or build CLI command.

Basically, establish a way to enable different modes, e.g.

# prod mode by default
$ greenwood --mode=debug|develop|prod 
  • debug: extra (meaningful) console logging (user config, graph) and writing out to files
  • develop: extra console logging like in debug mode but no writing out to files
  • prod: Just the basic status message we already see now

Details

A good use case would be disabling the Analytics plugin when developing, and thus only enabling it when building for production.

module.exports = (options = {}) => {
  ...

  return [{
    type: 'index',
    provider: (compilation) => {
      const hook = !compilation.config.production
        ? ''
        : `
            <script async src="https://www.googletagmanager.com/gtag/js?id=${analyticsId}"></script>
          
            <script>
              window.dataLayer = window.dataLayer || [];
              function gtag(){dataLayer.push(arguments);}
              gtag('js', new Date());

              gtag('config', '${analyticsId}', { 'anonymize_ip': ${trackAnon} });
              gtag('config', '${analyticsId}');
            </script>
          `
      };
     
     return {
       hookGreenwoodAnalytics: hook
     }
  }];
};
@thescientist13
Copy link
Member Author

As part of #355 this was simply done as an environment variable, but ideally this should be a little more ergonomic / less mutable.

@thescientist13 thescientist13 mentioned this issue Nov 12, 2020
12 tasks
@thescientist13 thescientist13 removed their assignment Mar 15, 2022
@thescientist13 thescientist13 added feature New feature or request and removed enhancement Improve something existing (e.g. no docs, new APIs, etc) labels Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI feature New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant