Pregunta

In an Aptana Studio 3 web project, is it possible to use JS libraries located in a different project?

I'm trying to create a JavaScript library and put it under source control, then create an example project that uses APIs in my library. As far as I can tell, there doesn't seem to be a way to do this. It appears to me that all of my HTML/CSS/JS files need to be located in the same project.

Am I missing something obvious?

EDIT

To clarify: if I have everything in 1 project, my folder structure looks like this

- Project\
   - index.html
   - JS/
       - myAwesomeLibrary.js
       - script.js

And I would reference my JS files like this

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

What I want to do is move myAwesomeLibrary into its own Aptana project:

- Library\
   - JS\
       -myAwesomeLibrary.js
- Project\
   - index.html
   - JS\
       - script.js

How do I make this work in HTML?

¿Fue útil?

Solución

It depends on where your Library project is located relative to your Project project. If they are both in the same parent folder, the src for your js could be as simple as

<script src="../Library/JS/myAwesomeLibrary.js"></script>

Meaning, go up one folder past where my current file is and then look for a folder called 'Library'. You can also use an absolute path using the address the internal browser uses - though you will have to change this for the final server. The absolute path would look something like:

<script src="http://127.0.0.1:8020/Library/JS/myAwesomeLibrary.js"></script>

Keep in mind, this may work in Aptana's internal browser, but your paths may change once you get the final server if the Library, for instance, is located in a different virtual host than the Project.

Otros consejos

For future reference: there is a way to make Aptana synchronize files between two projects by setting up a new connection with the source set to project 'Library' and destination project 'Project'.

I might actually use this method instead as it allows greater control over which project gets library updates and when, while also removing the need to set different script tags on the development server.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top