简体   繁体   中英

Different merged and minified js files in different htmls in one app

I have an express.js application, it renders pages on server and serves them on different routes - /home and /dashboard etc., for example, I use several js files, some on all pages, some not:

on home page I use: jquery.js, underscore.js, somemodule1.js, somemodule2.js

on dashboard: jquery.js, underscore.js , but somemodule3.js, somemodule4.js

I need to optimize an app, 'cause I don't want to include files on every html separately..

I need somehow to merge jquery and underscore in base-merged.js and other ones to home-merged.js and dashboard-merged.js . It would be nice to have them minified as well.

Do you now node.js module or maybe grunt plugin for that? The thing I've found - https://npmjs.org/package/merge-js but not sure this will work, I also tried to configure https://github.com/yeoman/grunt-usemin plugin with no luck..

Thanks!

Yes, by using one single minified js file you can easily achieve it.

You may try to use grunt-minified

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM