Skip to content

Commit 1c07733

Browse files
Add tailwind config for LSP support in templ files (#413)
1 parent 0c1cc7f commit 1c07733

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

cmd/program/program.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,18 @@ func (p *Project) CreateMainFile() error {
505505
return err
506506
}
507507

508+
htmxTailwindConfigJsFile, err := os.Create(fmt.Sprintf("%s/tailwind.config.js", projectPath))
509+
if err != nil {
510+
return err
511+
}
512+
defer htmxTailwindConfigJsFile.Close()
513+
514+
htmxTailwindConfigJsTemplate := advanced.HtmxTailwindConfigJsTemplate()
515+
err = os.WriteFile(fmt.Sprintf("%s/tailwind.config.js", projectPath), htmxTailwindConfigJsTemplate, 0o644)
516+
if err != nil {
517+
return err
518+
}
519+
508520
efsFile, err := os.Create(fmt.Sprintf("%s/%s/efs.go", projectPath, cmdWebPath))
509521
if err != nil {
510522
return err
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
content: ["./**/*.html", "./**/*.templ", "./**/*.go",],
3+
theme: { extend: {}, },
4+
plugins: [],
5+
}

cmd/template/advanced/routes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ var inputCssTemplate []byte
2828
//go:embed files/tailwind/output.css.tmpl
2929
var outputCssTemplate []byte
3030

31+
//go:embed files/htmx/tailwind/tailwind.config.js.tmpl
32+
var htmxTailwindConfigJsTemplate []byte
33+
3134
//go:embed files/htmx/htmx.min.js.tmpl
3235
var htmxMinJsTemplate []byte
3336

@@ -140,6 +143,10 @@ func OutputCssTemplate() []byte {
140143
return outputCssTemplate
141144
}
142145

146+
func HtmxTailwindConfigJsTemplate() []byte {
147+
return htmxTailwindConfigJsTemplate
148+
}
149+
143150
func HtmxJSTemplate() []byte {
144151
return htmxMinJsTemplate
145152
}

0 commit comments

Comments
 (0)