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

Add ability to customize the success message #67

Merged
merged 2 commits into from Jun 19, 2021

Conversation

astorije
Copy link
Contributor

This allows customization like the following successful notification:

Screen Shot 2021-04-25 at 7 46 07 PM

This can be done using the following configuration:

// webpack.config.ts
import WebpackBuildNotifierPlugin from 'webpack-build-notifier';

let address: string;

export default {
  // ... snip ...
  devServer: {
    // ... snip ...
    onListening(server) {
      const { port } = server.listeningApp.address();
      address = `http://localhost:${port}`;
    },
  },
  plugins: [
    // ... snip ...
    new WebpackBuildNotifierPlugin({
      formatSuccess() {
        return address
          ? `Your application is now running at ${address}`
          : undefined; // Fallback when not running the devServer
      },
    }),
  ],
  // ... snip ...
};

formatMessage is a () => string function instead of a simple string parameter so that it can be passed a dynamic value. This is useful in cases like the example above, where the message to display depends on a value set after the plugin has been initialized.

@coveralls
Copy link

coveralls commented Apr 26, 2021

Pull Request Test Coverage Report for Build 161

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 93.86%

Totals Coverage Status
Change from base Build 160: 0.2%
Covered Lines: 130
Relevant Lines: 134

💛 - Coveralls

@astorije
Copy link
Contributor Author

@RoccoC, rebased on master and fixed conflicts on that one as well. I expect this might cause further conflicts with #70 if you merge either of them, but I don't mind fixing conflicts while it's fresh :)

@astorije
Copy link
Contributor Author

astorije commented May 3, 2021

Rebased on master and fixed conflicts.

@RoccoC RoccoC merged commit 2406e2c into RoccoC:master Jun 19, 2021
@RoccoC
Copy link
Owner

RoccoC commented Jun 19, 2021

Merged and published in 2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants