Skip to content

Commit

Permalink
Configure Dummy app to serve ActionText assets
Browse files Browse the repository at this point in the history
Without adding the [`sassc-rails` gem][sassc-rails] as a dependency,
attempts include the `trix.js`-provided stylesheets into the Asset
Pipeline [result in an error][sassc-rails-error].

Additionally, this commit extends the `.github/workflows/tests.yml` to
[include NodeJS support][setup-node], and to install the Dummy
application's Yarn dependencies during the setup phase (through the
[`yarn:install` Rails task][yarn:install], and to [cache the installed
Yarn packages][cache].

Finally, declare `test/dummy/config/initializers/assets.rb` to [configure
the Asset Pipeline's search path][asset-initializer] to include the
_project root's_ `node_modules/` directory.

[sassc-rails]: https://github.com/sass/sassc-rails
[sassc-rails-error]: sass/sassc-rails#114
[setup-node]: https://github.com/actions/setup-node/tree/v1#usage
[yarn:install]: https://github.com/rails/webpacker/blob/v5.0.1/lib/tasks/webpacker/yarn_install.rake
[cache]: https://github.com/actions/cache/blob/v1/examples.md#node---yarn
[asset-initializer]: https://guides.rubyonrails.org/asset_pipeline.html#search-paths
  • Loading branch information
seanpdoyle committed Apr 12, 2020
1 parent c6f7c64 commit 5cdac6c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,35 @@ jobs:
with:
ruby-version: "${{ matrix.ruby }}"

- name: "Install NodeJS 12.x"
uses: "actions/setup-node@v1"
with:
node-version: "12.x"

- name: "Generate lockfile"
run: |
bundle config path vendor/bundle
bundle lock
- uses: "actions/cache@v1"
- name: "Cache installed Ruby dependencies"
uses: "actions/cache@v1"
with:
path: "vendor/bundle"
key: bundle-${{ hashFiles('Gemfile.lock') }}

- name: "Cache installed Yarn dependencies"
uses: "actions/cache@v1"
with:
path: "node_modules"
key: yarn-${{ hashFiles('yarn.lock') }}

- name: "Install Dependencies"
run: |
sudo apt-get update
sudo apt-get -yqq install libsqlite3-dev chromium-browser
bundle install --jobs 4 --retry 3
bin/rails app:yarn:install
bin/rails app:webdrivers:chromedriver:update
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ else
rails_constraint = "~> #{rails_version}.0"
end

gem "sassc-rails"
gem "rails", rails_constraint
gem "webpacker"
4 changes: 4 additions & 0 deletions test/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join("../../node_modules")

0 comments on commit 5cdac6c

Please sign in to comment.