forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request solidusio#5798 from mamhoff/support-tailwind-in-du…
…mmy-app Support Tailwind CSS in core dummy app
- Loading branch information
Showing
6 changed files
with
77 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.configure do |config| | ||
config.when_first_matching_example_defined(solidus_admin: true) do | ||
config.before(:suite) do | ||
system('bin/rails solidus_admin:tailwindcss:build') or abort 'Failed to build Tailwind CSS' | ||
Rails.application.precompiled_assets | ||
end | ||
end | ||
end |
60 changes: 60 additions & 0 deletions
60
admin/lib/solidus_admin/testing_support/dummy_app/rake_tasks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
|
||
namespace :solidus_admin do | ||
namespace :tailwindcss do | ||
desc "Build Tailwind CSS" | ||
task build: :dummy_environment do | ||
require "solidus_admin" | ||
require "tailwindcss/commands" | ||
|
||
config_file = <<~JS | ||
const adminRoot = "#{SolidusAdmin::Engine.root}" | ||
const solidusAdmin = require(`${adminRoot}/config/tailwind.config.js`) | ||
module.exports = { | ||
// Read how to use TailwindCSS presets: https://tailwindcss.com/docs/presets. | ||
presets: [solidusAdmin], | ||
content: [ | ||
// Include paths coming from SolidusAdmin. | ||
...solidusAdmin.content, | ||
// Include paths to your own components. | ||
`${__dirname}/../../../../app/components/admin/**/*`, | ||
`${__dirname}/../../../../lib/components/admin/**/*`, | ||
], | ||
} | ||
JS | ||
FileUtils.mkdir_p(DummyApp::Application.root.join("config")) | ||
File.write(DummyApp::Application.root.join("config/tailwind.config.js"), config_file) | ||
FileUtils.mkdir_p(DummyApp::Application.root.join("app/assets/stylesheets/solidus_admin")) | ||
FileUtils.cp( | ||
SolidusAdmin::Engine.root.join("app/assets/stylesheets/solidus_admin/application.tailwind.css"), | ||
DummyApp::Application.root.join("app/assets/stylesheets/solidus_admin/application.tailwind.css") | ||
) | ||
|
||
tailwindcss = Tailwindcss::Commands.executable | ||
|
||
tailwindcss_command = [ | ||
tailwindcss, | ||
"--config", DummyApp::Application.root.join("config/tailwind.config.js"), | ||
"--input", DummyApp::Application.root.join("app/assets/stylesheets/solidus_admin/application.tailwind.css"), | ||
"--output", DummyApp::Application.root.join("assets/builds/solidus_admin/tailwind.css") | ||
] | ||
|
||
sh tailwindcss_command.shelljoin | ||
end | ||
end | ||
end | ||
|
||
# Attach Tailwind CSS build to other tasks. | ||
%w[ | ||
assets:precompile | ||
test:prepare | ||
spec:prepare | ||
db:test:prepare | ||
].each do |task_name| | ||
next unless Rake::Task.task_defined?(task_name) | ||
|
||
Rake::Task[task_name].enhance(["solidus_admin:tailwindcss:build"]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters