user91579631 user91579631 - 1 year ago 97
Javascript Question

Minified file does not use minified module

I have a node.js folder which contains a main js file and several other js files which contain the functions that the main js file will import.

I have minified all the js files in this folder.

In the original main.js file, it calls another module with the following line;

var func= require('./func');

After minification, this line remains the same. However, func.js is changed to func.min.js after minification. Do I have to modify the minified file manually to have it import func.min.js this way?

var func= require('./func.min');

It is quite tedious to manually make changes to the minified file. What is the most efficient way to minify my js files and get the main.min.js working?

I am using Webstorm file watchers to minify the js files.

Answer Source

To get your main.js working, change the require line in main.js to;

var func= require('./func.min');

This will work because you are using Webstorm file watchers to minify the js files. Therefore, when func.js is changed, func.min.js will be automatically generated.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download