Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
connect-coffee-script
Advanced tools
It provide a simple Connect middleware to serve CoffeeScript files. It is modeled after the Stylus middleware.
This project was created after the drop of native support for CoffeeScript in latest Express. More specifically, Express droped the compiler middleware in its versions 2 and 3 (the current versions at the time of this writing).
Read the annoucement article for more information.
Using npm:
npm install connect-coffee-script
Function returning a Connect middleware with the given options
.
Options:
force
Always re-compilesrc
Source directory used to find .coffee filesdest
Destination directory used to output .js files when undefined defaults to src
compile
Custom compile function, accepting the arguments (str, options)
bare
Compile without a top-level function wrapperbaseDir
Base directory for path resolutionnewPrefix
Use the new declaration (//#
instead of //@
)prefix
Path which should be stripped from src
sourceMap
Generates source map filessourceMapRoot
but added back to the sourceMap url.Here we will setup the middleware with only the required src
option.
var coffeescript = require('connect-coffee-script');
var connect = require('connect');
var app = connect();
app.use(coffeescript({
src: __dirname,
bare: true
}));
app.use(connect.static(__dirname + '/public'));
app.listen(3000)
Here we set up the custom compile function so that we may
set the bare
option, or define additional functions.
By default the compile function simply renders the JavaScript.
function compile(str, options, coffeePath) {
options.bare = true;
return coffeeScript.compile(str, options);
}
Pass the middleware to Connect, grabbing "*.coffee" files from this directory
and saving .js files to ./public. Also supplying our custom compile
function.
Following that we have a static()
layer setup to serve the .js
files generated by CoffeeScript.
var coffeeScript = require('coffee-script');
var connectCoffeescript = require('connect-coffee-script');
var connect = require('connect');
var app = connect();
app.use(connectCoffeescript({
src: __dirname,
dest: __dirname + '/public',
compile: compile
}));
app.use(connect.static(__dirname + '/public'));
FAQs
Simple connect middleware to serve CoffeeScript files
The npm package connect-coffee-script receives a total of 4 weekly downloads. As such, connect-coffee-script popularity was classified as not popular.
We found that connect-coffee-script demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.