npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-production-console-filter

v1.0.1

Published

A Webpack configuration extension that removes console logs in production builds unless specified otherwise.

Downloads

19

Readme

Here’s a complete README.md for your webpack-production-console-filter package:


webpack-production-console-filter

A Webpack configuration extension that conditionally removes console.log statements in production builds. The logs are automatically removed unless the environment variable RETAIN_CONSOLE_LOGS is set to 'true'.

Installation

To use this package, first install it along with webpack-merge (if not already installed):

npm install webpack-production-console-filter webpack-merge --save-dev

Usage

To integrate the webpack-production-console-filter into your Webpack configuration, merge it into your existing Webpack configuration using webpack-merge.

Example webpack.config.js:

const merge = require('webpack-merge');
const productionConsoleFilter = require('webpack-production-console-filter');
const baseConfig = require('./webpack.config.base');

module.exports = merge(baseConfig, productionConsoleFilter());

Environment Variables

This extension relies on the following environment variables:

  • NODE_ENV: Set this to 'production' to enable the removal of console.log statements.
  • RETAIN_CONSOLE_LOGS: Set this to 'true' to retain console.log statements in production builds.

Example Scenarios

  1. Production build without console logs:

    NODE_ENV=production npm run build

    This will remove all console.log statements from the production build.

  2. Production build retaining console logs:

    NODE_ENV=production RETAIN_CONSOLE_LOGS=true npm run build

    In this case, console.log statements will be retained in the production build.

  3. Development build:

    npm run dev

    When NODE_ENV is not set to 'production', the console logs will always be retained.

Why Use webpack-production-console-filter?

This package simplifies the process of controlling console.log statements in your production builds. By using environment variables, you can easily toggle whether console logs are included in the final build, reducing file sizes and improving performance when needed.

License

This project is licensed under the MIT License.