Skip to content

Commit 354c1a2

Browse files
committed
Webpacker: Add tailwind.config.js
During webpack installation generate `tailwind.config.js`. This commit places that file inside `stylesheets/` dir, and link to it inside `postcss.config.js`. This is the blank Tailwind confg file that one can extend to bring its own esthetics.
1 parent 076857e commit 354c1a2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/install/tailwindcss_with_webpacker.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
run "yarn add tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9"
66
insert_into_file "#{Webpacker.config.source_entry_path}/application.js", "\nimport \"stylesheets/application\"\n"
77

8-
say "Adding minimal configuration for Tailwind CSS to work properly"
8+
say "Configuring Tailwind CSS"
99
directory Pathname.new(__dir__).join("stylesheets"), Webpacker.config.source_path.join("stylesheets")
10+
Dir.chdir(WEBPACK_STYLESHEETS_PATH) { run "npx tailwindcss init" }
11+
12+
insert_into_file "postcss.config.js", "require('tailwindcss')(\"./app/javascript/stylesheets/tailwind.config.js\"),\n ",
13+
before: "require('postcss-import')"
1014

11-
insert_into_file "postcss.config.js", "require('tailwindcss'),\n ", before: "require('postcss-import')"
1215

1316
if APPLICATION_LAYOUT_PATH.exist?
1417
say "Add Tailwindcss include tags in application layout"

0 commit comments

Comments
 (0)