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

Introduction to the properties of B-Tree

B-tree is a common data structure. Along with him...

Differences between FLOW CHART and UI FLOW

Many concepts in UI design may seem similar in wo...

How to implement h5 input box prompt + normal text box prompt

XML/HTML CodeCopy content to clipboard < input...

Mysql master-slave synchronization configuration scheme under Centos7 system

Preface Recently, when working on a high-availabi...

WeChat Mini Program implements the likes service

This article shares the specific code for the WeC...

MySQL complete collapse: detailed explanation of query filter conditions

Overview In actual business scenario applications...

Using vsftp to build an FTP server under Linux (with parameter description)

introduce This chapter mainly introduces the proc...

Docker+nacos+seata1.3.0 installation and usage configuration tutorial

I spent a day on it before this. Although Seata i...

Usage and scenario analysis of npx command in Node.js

npx usage tutorial Tonight, when I was learning V...

How to check and organize website files using Dreamweaver8

What is the purpose of creating your own website u...

How to build gitlab on centos6

Preface The original project was placed on the pu...

How to use yum to configure lnmp environment in CentOS7.6 system

1. Installation version details Server: MariaDB S...

MySQL integrity constraints definition and example tutorial

Table of contents Integrity constraints Definitio...

Using css-loader to implement css module in vue-cli

【Foreword】 Both Vue and React's CSS modular s...