cjohansen / juicer

A command line tool for JavaScript and CSS developers
630 stars 47 forks source link

Use absolute URL for JS files? #65

Open jackhand opened 11 years ago

jackhand commented 11 years ago

Is there a way to use absolute URLs for JS files?

Consider the following file structure of an app with 3 files: App.js (includes foo/Foo.js) foo/Foo.js (includes bar/Bar.js) bar/Bar.js

The root path is located where App.js is stored. I would like to construct a merge command so Juicer knows where the root path is and so I can write the include statement in Foo.js so it is relative to the root path (i.e. "depend bar/Bar.js") . I don't wish to write the import statement so it is relative to Foo.js (i.e. "depend ../bar/Bar.js")

I would like to be relative to the root, because other programming languages construct their import statements like this. Plus, it is much easier to copy and paste an import statement from another JS file (in possibly a different folder) w/o then having to figure out the relative path to the imported file.

Is this possible with the current version of Juicer?

jackhand commented 11 years ago

I think I may have figured it out.

1) Change all import statements so they are refer to the root path. Instead of "bar/Bar.js" or "../bar/Bar.js", it should be written "/bar/Bar.js"

2) Then the Juicer command line should be something the following: "juicer merge App.js -d "

This works for me. Is this the recommended way of achieving this?

jackhand commented 11 years ago

Correction: The command line should have included an absolute path after the -d command, like so: "juicer merge App.js -d 'C:\project\assets\js'"