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

@lzwme/strip-loader

v1.1.1

Published

A simple webpack loader to strip custom debug statements from your code.

Downloads

2

Readme

@lzwme/strip-loader

@lzwme/strip-loader

NPM version node version license MIT

build status npm download GitHub issues GitHub forks GitHub stars

A simple webpack loader to strip custom debug statements from your code. This can be useful if you want to use debug statements while developing your app but don't want this info exposed in your production code.

Getting Started

Installation

To begin, you'll need to install the loader with npm, yarn or pnpm:

# use npm
npm install -D @lzwme/strip-loader
# or use yarn
yarn add -D @lzwme/strip-loader
# or use pnpm
pnpm add -D @lzwme/strip-loader

Usage in webpack

In your webpack configuration object, you'll need to add @lzwme/strip-loader to your list of modules.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        // test: /\.(t|j)sx?$/,
        test: /\.(css|scss|less|jsx?|tsx?)$/,
        enforce: 'pre',
        exclude: /node_modules/,
        use: [
          {
            loader: require.resolve('@lzwme/strip-loader'),
            options: {
              disabled: process.env.NODE_ENV === 'development',
              // debug: false,
              // blocks: [{
              //   start: 'devblock:start',
              //   end: 'devblock:end',
              //   prefix: '/*',
              //   end: '*/',
              // }],
            },
          },
        ],
      },
    ];
  }
}

Use in your source files:

export class Abc {
  constructor() {
    console.log('test for production');

    /** devblock:start */
    this.test();
    /** devblock:end */
  }
  /* devblock:start */
  // this code block will be removed in production mode.
  private test() {
    console.log('test for development');
  }
  /* devblock:end */
}

Usage in rollup

import { rollupStripPlugin } from '@lzwme/strip-loader';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [
    strip({
      disabled: process.env.NODE_ENV !== 'production' ?,
      // includes: '**/*.(js|jsx|ts|tsx)',
      // exlude: 'tests/**/*',
      // debug: false,
      // blocks: [{
      //   start: 'devblock:start',
      //   end: 'devblock:end',
      //   prefix: '/*',
      //   end: '*/',
      // }],
    })
  ]
};

Options

| Name | Type | Default | Description | | :--------------------------: | :------------------: | :---------------------: | :----------------------------------------------- | | blocks | {object} | `` | You can customize the blocks config. | | blocks[i].start | {string} | devblock:end | You can customize the start comment tag. | | blocks[i].end | {string} | devblock:end | You can customize the end comment tag. | | blocks[i].preifx | {string} | /* | | | blocks[i].suffix | {string} | */ | | | isReplaceWithPlaceHolder | {boolean} | true | Replace the matched code block with placeholder. | | debug | {boolean} | false | Print some debugging information. | | disabled | {boolean} | false | Disable the loader. |

Example for Options.blocks

Config for files of js,css and html:

module.exports = {
  module: {
    rules: [
      {
        test: /\.css|scss|less|jsx?|tsx?|html?$/,
        enforce: 'pre',
        exclude: /node_modules/,
        use: [
          {
            loader: require.resolve('@lzwme/strip-loader'),
            options: {
              disabled: process.env.NODE_ENV === 'development',
              // debug: false,
              blocks: [
                {
                  start: 'devblock:start',
                  end: 'devblock:end',
                }, {
                  start: 'devblock:start',
                  end: 'devblock:end',
                  prefix: '<--',
                  end: '-->',
                }
              ],
            },
          },
        ],
      },
    ];
  }
}

Use in html file:

<div>for prod</div>

<!-- devblock:start --->
<div>for dev</div>
<!-- devblock:end --->

Development

git clone https://github.com/lzwme/strip-loader
pnpm install
pnpm test

License

@lzwme/strip-loader is released under the MIT license.

该插件由志文工作室开发和维护。