Skip to content

Commit

Permalink
Updating test and README for custom postcss.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmeij committed Jan 8, 2024
1 parent d00d83b commit 28d039e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ This also works with relative paths. If you've installed into your app's directo
TAILWINDCSS_INSTALL_DIR=node_modules/.bin
```

### Using a custom postcss.config.js

If you want to use a custom `postcss.config.js`, for example to enable nesting, you can place it in the `config` folder and it will be loaded automatically.

```
module.exports = {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
},
}
```

## Developing with Tailwindcss

Expand Down
21 changes: 21 additions & 0 deletions test/lib/tailwindcss/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,27 @@ def mock_local_tailwindcss_install
end
end

test ".compile_command when postcss.config.js exists" do
mock_exe_directory("sparc-solaris2.8") do |dir, executable|
Dir.mktmpdir do |tmpdir|
Rails.stub(:root, Pathname.new(tmpdir)) do # Rails.root won't work in this test suite
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")

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}")
end
end
end
end

test ".watch_command" do
mock_exe_directory("sparc-solaris2.8") do |dir, executable|
Rails.stub(:root, File) do # Rails.root won't work in this test suite
Expand Down

0 comments on commit 28d039e

Please sign in to comment.