Serve assets developed for Sprockets with Mincer
Add karma-sprockets-mincer
as a devDependency in your package.json
.
{
"devDependencies": {
"karma": "",
"karma-sprockets-mincer": ""
}
}
or
npm install karma-sprockets-mincer --save-dev
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
...
]
Optionally configure helpers that the assets might be using.
```coffeescript
sprocketsHelpers:
asset_path: (fileName) -> return "assets/#{fileName}"
You can also add sprockets paths from RubyGems if you are using this in a Ruby/Rails project.
# "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 show
and add them with the specified paths to Sprockets/Mincer.