Class: Jekyll::Tailwind

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-tailwind.rb,
lib/jekyll-tailwind/version.rb

Constant Summary collapse

VERSION =
"2.0"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Tailwind

Returns a new instance of Tailwind.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jekyll-tailwind.rb', line 11

def initialize(config)
  if config["config_path"]
    Jekyll.logger.warn "WARNING: The `config_path` option is deprecated and will be removed in the next releases. Please use the `config` option instead."
  end
  if config["version"]
    Jekyll.logger.warn "WARNING: The `version` option has no effect, version could be managed through 'tailwindcss-ruby' gem in you're Gemfile."
  end

  @config = config["config_path"] || config["config"] || "tailwind.config.js"
  @postcss = config.fetch("postcss", "postcss.config.js")
  @inputs = Array.wrap(config["input"])
  @output = config.fetch("output", "_site/assets/css/app.css")
  @minify = config.fetch("minify", false)
end

Instance Method Details

#compileObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jekyll-tailwind.rb', line 26

def compile
  command = [
            Tailwindcss::Ruby.executable,
            "--output", @output,
            "--config", @config,
          ]

  @inputs.each do |input|
    # There could be multiple input files or non at all.
    command += ["--input", input]
  end

  command += ["--minify"] if @minify
  command += ["--postcss", @postcss] if File.exist?(@postcss)

  `#{command.join(' ')}`
end