Play Framework:CSS文件无法在Heroku上运行

时间:2017-12-12 06:44:10

标签: css heroku playframework sbt

在CSS中我试图增加文字的字体。

输出:

在Localhost enter image description here

但是,在Heroku上部署时,以下是输出。

enter image description here

main.scala.html

@*
* This template is called from the `index` template. This template
* handles the rendering of the page header and body tags. It takes
* two arguments, a `String` for the title of the page and an `Html`
* object to insert into the body of the page.
*@
@(title: String)(content: Html)

<!DOCTYPE html>
<html lang="en">
<head>
    @* Here's where we render the page title `String`. *@
    <title>@title</title>
    <h1>Testing</h1>
    <link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
</head>
<body>
    @* And here's where we render the `Html` object containing
     * the page content. *@
    @content

    <script src="@routes.Assets.versioned("javascripts/main.js")" type="text/javascript"></script>
</body>
</html>

的main.css

h1 { font-size: 5em }

路由

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# An example controller showing a sample home page
GET     /                           controllers.HomeController.index

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.versioned(path="/public", file: Asset)

#GET     /public/*file               controllers.Assets.at(path="/public", file)

POST     /downloadreceipt               controllers.HomeController.downloadReceipt

GET     /displayreceipt                 controllers.HomeController.displayReceipt

部署方法: sbt stage deployHeroku

1 个答案:

答案 0 :(得分:0)

h1 {font-size:5em}应为h1 {font-size:5em; - 另外,确保你的css文件的位置在heroku上是正确的,你可以打开开发人员控制台并检查它是否已经加载。