Fork me on GitHub
#boot
<
2016-08-09
>
alandipert11:08:43

i wonder how they handled the cwd problem

lwhorton15:08:26

what’s a way to get images into your output ./target with boot such that I can reference them via url(‘images/foo.png’) in css? is it as simple as sift :move?

micha15:08:36

@lwhorton: the target task is what writes files to a directory in the filesystem

micha15:08:57

but that's not usually what you really need

micha15:08:12

like when you're developing you're probably running some knd of jetty server

micha15:08:35

the target directory isn't good for that, it's better to serve files from the classpath in dev

micha15:08:04

and when you deploy you're probably not deploying to your own machine, you're probably making an uberjar or war file or pushing things to s3

micha15:08:40

the sift task will move things around in the fileset, and correspondingly in the classpath

micha15:08:48

because the fileset determines the classpath

lwhorton15:08:02

so locally I can just make sure i’m serving images/ from wherever, but how do I package up that dir later to ensure it’s included?

micha15:08:39

included in what is the question 🙂

micha15:08:55

how do you deploy to production?

micha15:08:04

tomcat? uberjar? static site on s3?

lwhorton15:08:23

lets just assume I use a boot task to bunlde everything into the standard main.js and main.out dirs, then those two files are served from some s3 bucket

lwhorton15:08:06

i suppose just sifting images/* into __ would do it, i’m just not sure what _ should be

micha15:08:06

what is the path to the .cljs.edn file in the fileset?

lwhorton15:08:13

or perhaps it’s wiser to include images/ as a resource-path instead, but because it’s css referencing there’s nothing in the cljs compiler that would ever touch that resource

micha15:08:06

you want to have the images directory in the same folder as the .cljs.edn file

micha15:08:16

actually no

micha15:08:22

in the same folder as your html file

micha15:08:40

so you can refer to it with a relative URL

micha15:08:51

so you can ues the sift task to do that

lwhorton15:08:00

aha - i think that’s the key

lwhorton15:08:14

my real case is a bit more complex, where my images are stored … elsewhere

micha15:08:28

that is actually a simpler case

micha15:08:49

and it's what you end up doing anyway in produciton of course, because cdn etc

lwhorton15:08:02

project/images project/clj/ { the whole cljs project } project/clj/build.boot

micha15:08:05

in that case the images are separate from the application

micha15:08:31

so you can deploy them separately

lwhorton15:08:07

so a sift :move #{“../images” “resources/“} ?

micha15:08:20

it's doing replaceAll in there

micha15:08:32

so you will need to use references in the substitution

micha15:08:16

sift task takes a map of regex -> str

micha15:08:28

you can see this in the (doc sift) in the repl

micha15:08:31

like this

micha15:08:15

(sift :move {#"^.*/images/(.*)$" "resources/$1"})

micha15:08:21

not sure what the .. was in your example?

lwhorton15:08:55

sorry didn’t realize it was a regex

lwhorton15:08:08

im digging aroudn the docs/impl to figure this out, thanks for the great pointer