Skip to content

Webpacker: Add tailwind.config.js #33

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 1 commit into from
Feb 6, 2021
Merged
Changes from all commits
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
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.
  • Loading branch information
dixpac committed Feb 4, 2021
commit 354c1a2a264f36a398cc110758b582573941289a
7 changes: 5 additions & 2 deletions lib/install/tailwindcss_with_webpacker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
run "yarn add tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9"
insert_into_file "#{Webpacker.config.source_entry_path}/application.js", "\nimport \"stylesheets/application\"\n"

say "Adding minimal configuration for Tailwind CSS to work properly"
say "Configuring Tailwind CSS"
directory Pathname.new(__dir__).join("stylesheets"), Webpacker.config.source_path.join("stylesheets")
Dir.chdir(WEBPACK_STYLESHEETS_PATH) { run "npx tailwindcss init" }

insert_into_file "postcss.config.js", "require('tailwindcss')(\"./app/javascript/stylesheets/tailwind.config.js\"),\n ",
before: "require('postcss-import')"

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

if APPLICATION_LAYOUT_PATH.exist?
say "Add Tailwindcss include tags in application layout"
Expand Down