This section uses the Markdown-loader as an example: this loader is used to parse.md files. Interested you can follow my steps to see the effect. Webpack’s Loader is a function, so after creating a project, the steps are as follows:
The main files in the project are package.json and markdown-loader.js files. As long as you have this file, NPM publishing is ready to use. I created SRC just for testing purposes.
1.npm init
Name is the name of the loader. This is configured in webpack.config.js. Main is the entry file for the NPM export.
2. Parse the.md file
The markdown-loader.js file is as follows:
3. Release the NPM package
npm publish
Make sure your VSCode is already associated with NPM.
4. Use the loader
Set the following Settings in your project:
Write a test case
Create the mark.md file
6. Import in the JS file
7. Start the project
To release the NPM package, you just need to change your code and version number to release it, and then reinstall it in your own project.