Skip to content

Allow custom postcss.config.js #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
command postcss flag argument is a separate array member
following the convention used for assembling the overall command
  • Loading branch information
flavorjones committed Jan 10, 2024
commit 5caa7ebac34d2326e1c8b6162619fd65d09d147b
14 changes: 9 additions & 5 deletions lib/tailwindcss/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@ def executable(exe_path: DEFAULT_DIR)
end

def compile_command(debug: false, **kwargs)
[
command = [
executable(**kwargs),
"-i", Rails.root.join("app/assets/stylesheets/application.tailwind.css").to_s,
"-o", Rails.root.join("app/assets/builds/tailwind.css").to_s,
"-c", Rails.root.join("config/tailwind.config.js").to_s,
].tap do |command|
command << "--minify" unless (debug || rails_css_compressor?)
command << "--postcss #{Rails.root.join("config/postcss.config.js")}" if File.exist?(Rails.root.join("config/postcss.config.js"))
end
]

command << "--minify" unless (debug || rails_css_compressor?)

postcss_path = Rails.root.join("config/postcss.config.js")
command += ["--postcss", postcss_path.to_s] if File.exist?(postcss_path)

command
end

def watch_command(always: false, poll: false, **kwargs)
Expand Down
6 changes: 4 additions & 2 deletions test/lib/tailwindcss/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,17 @@ def mock_local_tailwindcss_install
actual = Tailwindcss::Commands.compile_command(exe_path: dir)
assert_kind_of(Array, actual)
assert_equal(executable, actual.first)
refute_includes(actual, "--postcss config/postcss.config.js")
refute_includes(actual, "--postcss")

config_file = Rails.root.join("config/postcss.config.js")
FileUtils.mkdir_p(Rails.root.join("config"))
FileUtils.touch(config_file)
actual = Tailwindcss::Commands.compile_command(exe_path: dir)
assert_kind_of(Array, actual)
assert_equal(executable, actual.first)
assert_includes(actual, "--postcss #{config_file}")
assert_includes(actual, "--postcss")
postcss_index = actual.index("--postcss")
assert_equal(actual[postcss_index + 1], config_file.to_s)
end
end
end
Expand Down