0

I'm trying to set up a blog using Hakyll, and I've been running into some issues with adding JavaScript files. I'm trying to follow the standard way of handling JavaScript files with Hakyll, but my .js files don't seem to be getting picked up by the compiler.

Here is the relevant part of my site.hs file:

main :: IO ()
main = hakyll $ do
    match "images/*" $ do
        route   idRoute
        compile copyFileCompiler

    match "js/*" $ do
        route   idRoute
        compile copyFileCompiler

...

My JavaScript file (script.js) is located in the js directory at the root level of my project. The file is not empty.

When I run my Hakyll site, the JavaScript file isn't copied into the _site directory as expected. I've tried using different matching patterns, like "js/script.js" and "**.js", but none of them seem to work.

I've also made sure that the tag in my HTML file is correctly referencing the JavaScript file:

<script src="/js/script.js"></script>

Running ls -l js/script.js shows that the file exists:

-rw-r--r--@ 1 dan  staff  35  2 Jul 23:10 js/script.js

I've tried cleaning and rebuilding the site multiple times, but the JavaScript file is never included in the _site directory. All other files (like images and CSS) are handled correctly.

I'm not sure what I'm doing wrong here. Any help would be greatly appreciated!

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Did you recompile the binary? – arrowd Jul 03 '23 at 10:50
  • @arrowd Thank you! I completely forgot. Cheers. That was messing with my head for a while. Just ran 'stack build' on the root repo and then followed up with 'stack exec site build' and it works. Thanks again. – equanimitus Jul 03 '23 at 11:08
  • You can use `stack run` so that stack will automatically recompile if necessary. – arrowd Jul 03 '23 at 11:52

0 Answers0