Skip to content

Latest commit

 

History

History

demo_app-gulp-alt

ExternalAssetPipeline Demo with Gulp and Webpack reading from two manifests

This example is the same as demo_app-gulp but showcasing how you can assemble a more complex integration with the ExternalAssetPipeline. This app integrates with two separate JSON manifests (gulp-manifest.json, for the gulp-compiled assets, and webpack-manifest.json, for the webpack-compiled assets). To achieve this, the app instantiates its own ExternalAssetPipeline::Manifest instances corresponding to each JSON file and combines them using the ExternalAssetPipeline::PriorityManifest. Finally, it overrides the external_asset_pipeline_manifest helper method to reference this custom manifest instance. See this commit for details.

This example uses gulp with gulp-rev and webpack with webpack-assets-manifest to build the assets and generate the manifest. Refer to the package.json, gulp tasks, and webpack.config.js to see the specifics.

In this example, sprockets has been completely removed. Thus, there's no more assets:precompile rake task, and in fact, there's no need to install gems, load the rails environment, or even have ruby installed to compile assets - the app's asset compilation is completely decoupled from rails! When that coupling exists, changes to ruby code may affect assets, but when they're completely separate, that's guaranteed to not be the case. Thus, we can easily determine when it's unnecessary to recompile assets and use that to reduce the overall build time.

Working with assets

Watch mode (incremental recompilation)

bin/yarn watch

Development build

bin/yarn build

Production build

NODE_ENV=production bin/yarn build