Webpack plugin for rails assets compatible manifest -
i'm trying replace rails asset pipeline webpack based pipeline. i've got dev setup webpack-dev-server
, hot reloading etc working beautifully. i'm trying achieve compilation step production mimic how rails compiles assets (digesting / generating compatible manifest.json file) such can still use helpers javascript_include_tag
etc. i'm stuck.
i've read lots of tutorials on using webpack rails, end writing own view helpers load assets. i'm trying avoid because don't want overhead or devs need understand different pipeline. want config asset_host=
work out of box using cdn etc.
ultimately, want similar gulp-rev-rails-manifest generates rails-asset-pipeline compatible manifest file on compilation, haven't found plugin (yet) exists webpack. so...
- is possible run webpack build through gulp stream using webpack only (ie not using gulp-webpack) can use above gulp plugin. reason don't want use gulp-webpack takes on entries / output etc , find whole setup confusing since exists in
webpack.config
or
- does have decent resources on writing plugins webpack. seems bit of black box me , official site has menu section "how write plugin" it's not link anything.
or
- is there plugin , don't know how search on interwebs.
any appreciated :)
running webpack in gulp task very simple:
var webpack = require('webpack'); var webpackconfig = require('./webpack.config'); gulp.task('webpack', function(done) { webpack(webpackconfig, function(err, stats) { done(err); }); });
note stats
object provided webpack callback contains information assets emitted webpack, potentially use generate own manifest.
here few webpack plugins might find useful:
- https://github.com/sporto/assets-webpack-plugin
- https://github.com/danethurber/webpack-manifest-plugin
- https://github.com/diurnalist/chunk-manifest-webpack-plugin
while there no official tutorial on how create plugin, there's still plugin api doc describes different interfaces plugins can hook into. webpack source , github contain lot of webpack plugin examples.
here's simple plugin logs assets:
module.exports = function() { this.plugin('done', function(stats) { console.log(stats.tojson().assets); }); };
Comments
Post a Comment