From ecb282a2f949c44ff6028364858fd29773f755e1 Mon Sep 17 00:00:00 2001 From: Maciej Katafiasz Date: Wed, 6 Mar 2024 20:17:05 -0800 Subject: [PATCH] Fix tests and README --- README.md | 3 ++- lektor_tailwind.py | 5 ++++- tests/example/tailwind.config.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f640f13..b361b3f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ A Lektor plugin that adds Tailwind CSS to your project seamlessly. ```javascript module.exports = { - content: ['./templates/**/*.{html,j2}'], + // './' refers to the lektor build output directory, NOT the project dir + content: ['./**/*.html'], theme: { extend: {}, }, diff --git a/lektor_tailwind.py b/lektor_tailwind.py index 75e7150..08e8bf1 100644 --- a/lektor_tailwind.py +++ b/lektor_tailwind.py @@ -46,8 +46,11 @@ def _get_tailwind_args(self, output_path, *extra_args): def input_exists(self) -> bool: return os.path.exists(self.input_css) + def should_minify(self) -> bool: + return not self.watch or os.environ.get("NODE_ENV") == "production" + def compile_css(self, output_path: str): - minify = [] if self.watch else ["--minify"] + minify = ["--minify"] if self.should_minify() else [] subprocess.run( self._get_tailwind_args(output_path, *minify), check=True, diff --git a/tests/example/tailwind.config.js b/tests/example/tailwind.config.js index 9b99583..c777e5d 100644 --- a/tests/example/tailwind.config.js +++ b/tests/example/tailwind.config.js @@ -1,7 +1,7 @@ const colors = require("tailwindcss/colors"); module.exports = { - content: ["./templates/**/*.html"], + content: ["./**/*.html"], theme: { extend: { colors: {