user375566
user375566

Reputation:

Play! 2.0.1 - css in assets

Underneath the app directory, I can reference a javascript file, ajavascriptfile.js, inside of a package, from an html document:

<script src="/assets/css/test/ajavascriptfile.js"></script>

enter image description here

However, I can't reference the css file, acssfile.css, inside of an html document:

<script src="/assets/css/test/acssfile.css"></script>

No error is thrown except in the console, which states the file is not found. Is there a route I'm missing? For organization, it just seems makes sense to use packages to manage them, as opposed to the public folders (where I'm putting 3rd party files).

Upvotes: 3

Views: 641

Answers (2)

knuton
knuton

Reputation: 3597

H.Buzz is right, the way assets work in Play 2.0, you need to put your static assets in public/, not app/assets/. Out of the box, the only files in app/assets/ that are being handled by Play are those ending in .js, .coffee or .less.

Your JavaScript file is being copied as part of its being compiled by the Google Closure Compiler. For CSS files there is no equivalent processing, so it does not get copied.

You need to either put the file into public/ or extend Play's asset handling.

Upvotes: 2

user1425431
user1425431

Reputation: 39

  1. check file

{projectfolder}/public/css/test/acssfile.css

  1. edit code

link rel="stylesheet" media="screen" href="@routes.Assets.at("css/test/acssfile.css")">

:)

Upvotes: 0

Related Questions