From da7b43ed8338b7bbbfcb1b00eb2a6d117bd1052b Mon Sep 17 00:00:00 2001 From: "Hodel Lukas, ENT-BPN-BAN-PDC-SWE-2" Date: Sun, 7 Feb 2021 17:31:51 +0100 Subject: [PATCH] Faster webpack compile time When adding custom css into a separate file webpack does not have to compile the whole tailwindcss again but only the changes in application.scss --- lib/install/stylesheets/application.scss | 3 --- lib/install/stylesheets/tailwindcss/after.scss | 2 ++ lib/install/stylesheets/tailwindcss/before.scss | 1 + lib/install/tailwindcss_with_webpacker.rb | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 lib/install/stylesheets/tailwindcss/after.scss create mode 100644 lib/install/stylesheets/tailwindcss/before.scss diff --git a/lib/install/stylesheets/application.scss b/lib/install/stylesheets/application.scss index 76fcadcc..e69de29b 100644 --- a/lib/install/stylesheets/application.scss +++ b/lib/install/stylesheets/application.scss @@ -1,3 +0,0 @@ -@import "tailwindcss/base"; -@import "tailwindcss/components"; -@import "tailwindcss/utilities"; diff --git a/lib/install/stylesheets/tailwindcss/after.scss b/lib/install/stylesheets/tailwindcss/after.scss new file mode 100644 index 00000000..1d6234e6 --- /dev/null +++ b/lib/install/stylesheets/tailwindcss/after.scss @@ -0,0 +1,2 @@ +@import "tailwindcss/components"; +@import "tailwindcss/utilities"; diff --git a/lib/install/stylesheets/tailwindcss/before.scss b/lib/install/stylesheets/tailwindcss/before.scss new file mode 100644 index 00000000..8510da38 --- /dev/null +++ b/lib/install/stylesheets/tailwindcss/before.scss @@ -0,0 +1 @@ +@import "tailwindcss/base"; diff --git a/lib/install/tailwindcss_with_webpacker.rb b/lib/install/tailwindcss_with_webpacker.rb index b80c637f..9b2be2d8 100644 --- a/lib/install/tailwindcss_with_webpacker.rb +++ b/lib/install/tailwindcss_with_webpacker.rb @@ -3,7 +3,10 @@ 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", + "\nimport \"stylesheets/tailwindcss/before\""\ + "\nimport \"stylesheets/application\""\ + "\nimport \"stylesheets/tailwindcss/after\"\n" say "Configuring Tailwind CSS" directory Pathname.new(__dir__).join("stylesheets"), Webpacker.config.source_path.join("stylesheets")