Project

parceler

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
An alternative Parcel-powered asset manager and compiler, meant for Rails but built for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0

Runtime

 Project Readme

Parceler

version downloads license

DEPRECATED: This package is no longer maintained. I recommend migrating to Rails' Webpacker and webpacker-pnpm.

Parceler attempts to be an alternative asset compiler and manager for Ruby on Rails. It provides functionality similar to Rails' own Webpacker gem but is powered by Parcel instead of Webpack. As a result and at the cost of some more advanced features, it requires significantly less out-of-the-box configuration. While meant for Rails, nothing inhibits using this gem outside of a Rails context.

Installation

You can install this gem by adding it to your application's Gemfile via:

  gem 'parceler', group: :development

This gem also requires a Node.js environment set up with Yarn. You can install Node.js at https://nodejs.org/en/download/ and Yarn at https://yarnpkg.com/en/docs/install.

To install the required Node packages, run the rake task parceler:install:

  $ bundle exec rake parceler:install

Configuration

Before this gem can bundle your app's assets, it must be configured. To do so, you must run Parceler.configure with a provided configuration block before starting your app's server. The default configuration block that is packaged with this gem looks something like this:

# Configuration options defined here have direct relations to those defined in the official documentation.
# https://parceljs.org/cli.html
Parceler.configure do |c|
    c.entry_point = "app/javascript/application.js"
    c.destination = "public/parcels"
    c.cache = nil
    c.source_maps = false
    c.autoresolve = false

    # The following options only have an effect in production builds. You can parcel
    # your assets for production with rake tasks `parceler:build` or `assets:precompile`.
    c.minify = true
    c.content_hashing = true
end

If you do not want to customize your app, you may simply copy this block and everythig should work fine. However, it is very likely that you will need to customize it to your particular needs.

Configuration on Rails

While the above steps are not explicitly required, it is highly recommended that you create a config file so you can customize this gem to align with your own app. You can generate the default configuration initializer by running

  $ rails g parceler

, which will place a new file at config/initializers/parceler.rb.

Origin Story

I built this gem while working on the MAIS™ business managment and information system developed by sdbase. At the time of development, we were looking at upgrading the entire stack from EOLed versions of Ruby and Rails. Throughout the process, I realized that the new asset management system (webpacker) was overly complicated for many of our applications. As a result, it provided a reasonably steep learning curve to many of the burgeoning developers with which we were working. To mitigate those problems and to simplify the engineering learning process, I built Parceler to require very little out-of-the-box configuration while maintaining very transparent functionality.

License

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.