How to debug loader plugin in webpack project

How to debug loader plugin in webpack project

Recently, when I was learning how to use webpack, I found that the webpack-replace-loader configuration regular expression did not work. After debugging the plug-in, I found that the search key value did not support regular expression writing. Later, I switched to the string-replace-loader plug-in. The search key value of this loader supports regular expression writing, and the problem was solved. Here is the debugging method of loader:

First you need to prepare the node environment

Step 1: Download and install node-nightly globally

npm install -g --save-dev node-nightly

Step 2: Add debugging commands

 "node-nightly": "node-nightly --inspect-brk ./node_modules/webpack/bin/webpack.js",

Step 3: npm run node-nightly in the command line

Step 4: Open Google Chrome and enter chrome://inspect/#devices in the URL

Click inspect to enter the debugging page

Step 5: Find the index.js file of loader in node_module in vscode, and add debugger in the module.exports function;

At this point, you can debug the corresponding loader script as you normally debug js.

This is the end of this article on how to debug loader plugins in webpack projects. For more information about webpack debugging loader plugins, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Electron-vue uses webpack to package multiple pages of entry files
  • Implementation of webpack code fragmentation
  • 80 lines of code to write a Webpack plugin and publish it to npm
  • Implementation steps for building multi-page programs using Webpack
  • 50 lines of code to implement Webpack component usage statistics
  • webpack -v error solution

<<:  Detailed explanation of the solution to the failure of VMware to open the module diskearly

>>:  Introduction to using MySQL commands to create, delete, and query indexes

Recommend

10 HTML table-related tags

In fact many people will say “I’ve seen that table...

Why is there this in JS?

Table of contents 1. Demand 2. Solution 3. The fi...

Docker implements cross-host container communication based on macvlan

Find two test machines: [root@docker1 centos_zabb...

VMware virtual machine installation CentOS 8 (1905) system tutorial diagram

The world-famous virtual machine software VMware-...

TortoiseSvn Little Turtle Installation Latest Detailed Graphics Tutorial

There were always problems when installing tortoi...

Vendor Prefix: Why do we need a browser engine prefix?

What is the Vendor Prefix? Vendor prefix—Browser ...

Implementing parameter jump function in Vue project

Page Description:​ Main page: name —> shisheng...

CSS example code for implementing sliding doors

The so-called sliding door technology means that ...

How to export CSV file with header in mysql

Refer to the official document http://dev.mysql.c...

Raspberry Pi msmtp and mutt installation and configuration tutorial

1. Install mutt sudo apt-get install mutt 2. Inst...

WeChat applet custom bottom navigation bar component

This article example shares the specific implemen...

Detailed explanation of the principle and usage of MySQL views

This article uses examples to illustrate the prin...

How to change the dot in the WeChat applet swiper-dot into a slider

Table of contents background Target Effect Ideas ...

Detailed explanation of MySQL 8.0 password expiration policy

Starting from MySQL 8.0.16, you can set a passwor...

How to effectively compress images using JS

Table of contents Preface Conversion relationship...