Minimize .JS and CSS files in bulk

1

I'd like to know if you know of any tool that can minify files in js and css by mass, there are several files in a main folder in hundreds of subfolders, I'm using Node.js where I have several modules in these subfolders, and would like to minify the possible files in order to improve the final processing of the app.

    
asked by anonymous 05.08.2017 / 23:46

1 answer

3

It depends on which Web framework you are using with Node.js, if it is Express (the most common) there are:

express-minify

To install use:

npm install express-minify

It combines everything in and sends to the request response:

app.use(minify());
app.use(express.static(__dirname + '/static'));
app.get('/tudo.min.js', function(req, res)
{
    res.setHeader('Content-Type', 'application/javascript');
    res.end(responseJS);
});

It could request like this: <script src="/tudo.min.js"></script> , it also has cache of this combined version of the files:

express-minify-plus

It is a modification of express-minify , to install use:

npm i express-minify-plus
06.08.2017 / 00:10