Sprockets Pre-Loader for Webpack
- Vendor assets in
- Gem assets (resulting from
bundle show <gem>)
- JST Eco assets
npm install --save sprockets-preloader
Include as a
webpack-railsgem to integrate webpack asset helpers in Rails
non_webpack_compatible_before_webpacksprocket asset for all
non_webpack_compatible_after_webpacksprocket asset for all
.erbassets dependent on webpack assets
- Note: any gem's
erbdependencies should be included in either of the above files
coffee-loaderto parse CoffeeScript files
eco-loaderto parse Eco files
varexpressions actually polluted the global closure. Removing the
varkeyword should suffice as a transition remedy.
Another configuration example
webpack.config.js should contain something similarly to:
module:preLoaders:loader: requireloaders:test: /\.coffee$/ loader: requiretest: /\.eco$/ loader: require
application.html.erb should contain something similarly to:
For a more automated approach, consider using another Mavenlink loader: kitno-loader. Although currently in an alpha stage, its goal is to automagically convert (CoffeeScript) files into CommonJS-compliant modules.
As always, once these loaders have reach stability in your codebase, it is encouraged to write to disk.