devtools-ignore-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

npm node npm

DevTools Ignore Webpack Plugin

A Webpack plugin to ignore-listing code in Chrome devtools. To see how ignore-listing helps your development experience, check out this offical demo. This plugin is based on the plugin implemented in Angular CLI project.

Note: This plugin is only for Webpack 5.

Installation

npm install --save-dev devtools-ignore-webpack-plugin

Usage

First, follow webpack's guide to enable source maps in your project. Please note that the "inline" source map options are not supported yet.

Then, add the plugin to your webpack config:

const DevToolsIgnorePlugin = require("devtools-ignore-webpack-plugin");

module.exports = {
  // ...,
  plugins: [new DevToolsIgnorePlugin()],
};

Options

Currently, this plugin supports two options: shouldIgnorePath and isSourceMapAsset.

shouldIgnorePath

shouldIgnorePath is a function that checks whether a source file should be ignored. The function takes a single argument, which is the path of the file. It should return a boolean value.

new DevToolsIgnorePlugin({
  shouldIgnorePath: function (path) {
    if (path.includes("my-lib")) {
      return false;
    }
    return path.includes("/node_modules/") || path.includes("/webpack/");
  },
});

When not specified, the default function is:

function defaultShouldIgnorePath(path) {
  return path.includes("/node_modules/") || path.includes("/webpack/");
}

isSourceMapAsset

isSourceMapAsset is a function that checks whether a map file is potentially a source map asset. The function takes a single argument, which is the name of the potential source map asset. It should return a boolean value.

Note: This should rarely be needed. Known scenarios include only looking at .js.map in rare scenarios where you have other files that end in .map

new DevToolsIgnorePlugin({
  isSourceMapAsset: function (name) {
    return name.endsWith(".js.map"); // if you have other files that end in .map
  },
});

When not specified, the default function is:

function defaultisSourceMapAsset(name) {
  return name.endsWith(".map");
}

/devtools-ignore-webpack-plugin/

    Package Sidebar

    Install

    npm i devtools-ignore-webpack-plugin

    Weekly Downloads

    984

    Version

    0.1.2

    License

    MIT

    Unpacked Size

    13.7 kB

    Total Files

    7

    Last publish

    Collaborators

    • mondaychen