node.js - How should I handle javascript-files in express.js? -
i use express.js create front-end application. want run javascript can't find way handle in docs. there solutions out there merge, compress, gzip , include javascripts? in middleman rubyonrails can include files:
//= require vendor/_slideout18 //= require vendor/_flickity //= require vendor/_sprint //= require fastclick //= require reqwest //= require js.cookie //= require utils/utils //= require modules/state //= require modules/navigation_button
using koala-app, can prepend js-files other js-files:
// @koala-prepend "modules/alts.js" // @koala-prepend "modules/expandable.js" // @koala-prepend "modules/otherquestions.js"
is there similar in node? prefer if didn't require external application, grunt.
maybe try express static middleware , express compress middleware
var express = require('express'); var app = express(); app.use(express.compress()); app.use(express.static(__dirname + '/public'));
here 1 sample link
for merge js files, here 1 module named merge-js
used in 1 middleware of express add merge multiple js files according dependencies on each other , produce combined js file uglifying result.
app.use(require("merge-js").middleware({ src: __dirname + "/assets", dest: __dirname + "/public" }));
in case, merge looks js files in /assets dir , compiles them /public dir.
Comments
Post a Comment