Skip to content

Commit 28d039e

Browse files
committed
Updating test and README for custom postcss.config.js
1 parent d00d83b commit 28d039e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Diff for: README.md

+14
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ This also works with relative paths. If you've installed into your app's directo
3838
TAILWINDCSS_INSTALL_DIR=node_modules/.bin
3939
```
4040

41+
### Using a custom postcss.config.js
42+
43+
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.
44+
45+
```
46+
module.exports = {
47+
plugins: {
48+
'postcss-import': {},
49+
'tailwindcss/nesting': {},
50+
tailwindcss: {},
51+
autoprefixer: {},
52+
},
53+
}
54+
```
4155

4256
## Developing with Tailwindcss
4357

Diff for: test/lib/tailwindcss/commands_test.rb

+21
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,27 @@ def mock_local_tailwindcss_install
151151
end
152152
end
153153

154+
test ".compile_command when postcss.config.js exists" do
155+
mock_exe_directory("sparc-solaris2.8") do |dir, executable|
156+
Dir.mktmpdir do |tmpdir|
157+
Rails.stub(:root, Pathname.new(tmpdir)) do # Rails.root won't work in this test suite
158+
actual = Tailwindcss::Commands.compile_command(exe_path: dir)
159+
assert_kind_of(Array, actual)
160+
assert_equal(executable, actual.first)
161+
refute_includes(actual, "--postcss config/postcss.config.js")
162+
163+
config_file = Rails.root.join("config/postcss.config.js")
164+
FileUtils.mkdir_p(Rails.root.join("config"))
165+
FileUtils.touch(config_file)
166+
actual = Tailwindcss::Commands.compile_command(exe_path: dir)
167+
assert_kind_of(Array, actual)
168+
assert_equal(executable, actual.first)
169+
assert_includes(actual, "--postcss #{config_file}")
170+
end
171+
end
172+
end
173+
end
174+
154175
test ".watch_command" do
155176
mock_exe_directory("sparc-solaris2.8") do |dir, executable|
156177
Rails.stub(:root, File) do # Rails.root won't work in this test suite

0 commit comments

Comments
 (0)