karma-sprockets-mincer
v1.2.0
Published
Serve assets developed for Sprockets with Mincer
Downloads
1,236
Maintainers
Readme
karma-sprockets-mincer
Serve assets developed for Sprockets with Mincer
Installation
Add karma-sprockets-mincer
as a devDependency in your package.json
.
{
"devDependencies": {
"karma": "",
"karma-sprockets-mincer": ""
}
}
or
npm install karma-sprockets-mincer --save-dev
Configuration
Add the plugin to your config file.
plugins: [
'karma-phantomjs-launcher'
[...]
'karma-sprockets-mincer'
]
Then add sprockets-mincer
to the top of the frameworks list (order is important).
frameworks: [
"sprockets-mincer"
"jasmine"
]
Next, configure the paths that the Sprockets (Mincer) environment should know about.
sprocketsPaths: [
'app/assets/javascripts'
'lib/assets/javascripts'
'vendor/assets/javascripts'
]
Then, configure the js bundle files that Sprockets should generate. These files will be regenerated whenever a sprockets environment file changes.
sprocketsBundles: [
'application.coffee'
]
Be sure to also add files listed in sprocketsBundles
to config.files
in the correct place. sprockets-mincer
will replace the pattern
in config.files
with the one that is compiled.
files: [
...
'application.coffee' # this pattern will be replaced automatically
...
]
Helpers
You can add helpers that the assets might be using:
sprocketsHelpers:
asset_path: (fileName) -> return "assets/#{fileName}"
RubyGems
If you are using this in a Ruby/Rails project, you can add the rubygem paths as well:
# "gem-name": ["array of", "sprockets paths"]
rubygems: {
"rails-widget": ["lib/assets/javascripts", "vendor/assets/javascripts"]
"jquery-rails": ["vendor/assets/javascripts"]
}
This will run grab the path of the bundled gem by running bundle info --path
and add them with the specified paths to Sprockets/Mincer.
Additional Mincer engines
The path to engine file can be both absolute or relative to basePath
.
# "extension": "path-to-engine-definition-file.js"
mincerEngines: {
".hbs": "./lib/handlebarsjst.js",
".xxx": "/opt/mincer-ext/engine.js"
}