Thursday 11 May 2017

What's the best way to load assets in staging/production environments with nodejs?

I'm going to start a new nodejs application and I'm not sure what approach to choose to load my js/css files on staging and bundle them to production.In my work, we have an app that is setup like this:/config/all.js: this file contains arrays with filepaths. Different arrays for lib assets and own assets. This means that everytime a new file is added, I need to include the filepath on this file.In my footer.jade:if (process.env.NODE_ENV == 'development') for jsFile in jsFiles script(type='text/javascript', src=jsFile) else script(type='text/javascript', src='js/application.min.js')where jsFiles is the array with all the javascript filepaths the app has to load. In staging environment, we run grunt build so grunt takes care of concatening and bundling all assets. We're not using ES6 import.Is this a good approach to this problem? Should I be using webpack (though I'm not 100% sure what it is yet) or something?

Submitted May 11, 2017 at 08:06PM by pietrofxq

No comments:

Post a Comment