From 4a699c50a92642d1bea9e6cb8de883b9dc824f17 Mon Sep 17 00:00:00 2001 From: Lukas Hodel Date: Tue, 9 Feb 2021 19:12:15 +0100 Subject: [PATCH] Faster webpack recompilation --- lib/install/stylesheets/application.scss | 3 --- lib/install/stylesheets/base.scss | 4 ++++ lib/install/stylesheets/components.scss | 4 ++++ lib/install/stylesheets/components/.keep | 0 lib/install/stylesheets/utilities.scss | 4 ++++ lib/install/tailwindcss_with_webpacker.rb | 6 +++++- 6 files changed, 17 insertions(+), 4 deletions(-) delete mode 100644 lib/install/stylesheets/application.scss create mode 100644 lib/install/stylesheets/base.scss create mode 100644 lib/install/stylesheets/components.scss create mode 100644 lib/install/stylesheets/components/.keep create mode 100644 lib/install/stylesheets/utilities.scss diff --git a/lib/install/stylesheets/application.scss b/lib/install/stylesheets/application.scss deleted file mode 100644 index 76fcadc..0000000 --- a/lib/install/stylesheets/application.scss +++ /dev/null @@ -1,3 +0,0 @@ -@import "tailwindcss/base"; -@import "tailwindcss/components"; -@import "tailwindcss/utilities"; diff --git a/lib/install/stylesheets/base.scss b/lib/install/stylesheets/base.scss new file mode 100644 index 0000000..86c139d --- /dev/null +++ b/lib/install/stylesheets/base.scss @@ -0,0 +1,4 @@ +@import "tailwindcss/base"; + +// Add custom base styles here +// https://tailwindcss.com/docs/adding-base-styles diff --git a/lib/install/stylesheets/components.scss b/lib/install/stylesheets/components.scss new file mode 100644 index 0000000..2992da8 --- /dev/null +++ b/lib/install/stylesheets/components.scss @@ -0,0 +1,4 @@ +@import "tailwindcss/components"; + +// Import components added to `./components/` here +// https://tailwindcss.com/docs/extracting-components diff --git a/lib/install/stylesheets/components/.keep b/lib/install/stylesheets/components/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/install/stylesheets/utilities.scss b/lib/install/stylesheets/utilities.scss new file mode 100644 index 0000000..37d0097 --- /dev/null +++ b/lib/install/stylesheets/utilities.scss @@ -0,0 +1,4 @@ +@import "tailwindcss/utilities"; + +// Import vendor CSS here +// https://tailwindcss.com/docs/adding-new-utilities diff --git a/lib/install/tailwindcss_with_webpacker.rb b/lib/install/tailwindcss_with_webpacker.rb index b80c637..b15cb0b 100644 --- a/lib/install/tailwindcss_with_webpacker.rb +++ b/lib/install/tailwindcss_with_webpacker.rb @@ -3,7 +3,11 @@ say "Installing Tailwind CSS" 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" +insert_into_file "#{Webpacker.config.source_entry_path}/application.js", + "\n// Imported separately for faster Webpack recompilation. Order matters\""\ + "\nimport \"stylesheets/base\""\ + "\nimport \"stylesheets/components\""\ + "\nimport \"stylesheets/utilities\"\n" say "Configuring Tailwind CSS" directory Pathname.new(__dir__).join("stylesheets"), Webpacker.config.source_path.join("stylesheets")