scss资产无法在heroku部署上编译,但在本地运行时可以

时间:2019-05-26 17:56:01

标签: ruby heroku deployment sass jekyll

我最近尝试将我的Jekyll网站推到Heroku。经过大量的反复试验,现在可以加载网站本身,但没有任何样式。我非常确定这不是relative_url的问题,因为我确保将{{ site.baseurl }}放在所有资产路径的前面。在运行jekyll serve时,一切都在本地正常运行。

这是我的config.ru文件:

require 'rack'
require 'rack/contrib/try_static'

# enable compression
use Rack::Deflater

# static configuration (file path matches reuest path)
use Rack::TryStatic,
      :root => "_site",  # static files root dir
      :urls => %w[/],    # match all requests
      :try => ['.html', 'index.html', '/index.html'], # try these postfixes sequentially
      :gzip => true,     # enable compressed files
      :header_rules => [
        [:all, {'Cache-Control' => 'public, max-age=86400'}],
        [['scss', 'css', 'js'], {'Cache-Control' => 'public, max-age=604800'}]
      ]

# otherwise 404 NotFound
notFoundPage = File.open('_site/index.html').read
run lambda { |_| [200, {'Content-Type' => 'text/html'}, [notFoundPage]]}

这是我的Rakefile:

task "assets:precompile" do
  exec("jekyll build")
end

还有我的Procfile:

web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}

运行heroku日志--tail给出:

2019-05-26T17:20:00.358197+00:00 heroku[router]: at=info method=GET path="/press/assets/main.css" host=agile-savannah-64601.herokuapp.com request_id=e3465eb5-26a6-425c-9c25-6c818ddc0b07 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2516 protocol=https
2019-05-26T17:20:00.362877+00:00 heroku[router]: at=info method=GET path="/press/assets/js/api.js" host=agile-savannah-64601.herokuapp.com request_id=81f2979a-bdad-4319-a0ce-41d71e4f375e fwd="82.16.157.125" dyno=web.1 connect=1ms service=2ms status=200 bytes=2516 protocol=https
2019-05-26T17:20:00.483024+00:00 heroku[router]: at=info method=GET path="/press/assets/minima-social-icons.svg" host=agile-savannah-64601.herokuapp.com request_id=4cc63dfb-e01b-4e80-8bdd-b8e8f071c58a fwd="82.16.157.125" dyno=web.1 connect=0ms service=1ms status=200 bytes=2516 protocol=https
2019-05-26T17:25:17.490876+00:00 heroku[router]: at=info method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=1c04a322-83b3-417b-a4e7-2ad47a2c956a fwd="82.16.157.125" dyno=web.1 connect=0ms service=1ms status=304 bytes=86 protocol=https
2019-05-26T17:25:17.719209+00:00 heroku[router]: at=info method=GET path="/press/assets/main.css" host=agile-savannah-64601.herokuapp.com request_id=9b2042c2-2a50-4f0c-968f-32a21b097896 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2516 protocol=https
2019-05-26T17:25:17.726508+00:00 heroku[router]: at=info method=GET path="/press/assets/js/api.js" host=agile-savannah-64601.herokuapp.com request_id=504256e2-8b0c-4f5b-9dd9-44739f79d5af fwd="82.16.157.125" dyno=web.1 connect=0ms service=3ms status=200 bytes=2516 protocol=https
2019-05-26T17:25:17.843554+00:00 heroku[router]: at=info method=GET path="/press/assets/minima-social-icons.svg" host=agile-savannah-64601.herokuapp.com request_id=38d6704f-31b8-4a39-a025-7fb30ba42ce5 fwd="82.16.157.125" dyno=web.1 connect=1ms service=5ms status=200 bytes=2516 protocol=https
2019-05-26T17:32:08.000000+00:00 app[api]: Build started by user jamiereecebowman@gmail.com
2019-05-26T17:32:29.660345+00:00 heroku[web.1]: Restarting
2019-05-26T17:32:29.664628+00:00 heroku[web.1]: State changed from up to starting
2019-05-26T17:32:29.241973+00:00 app[api]: Deploy 3077cbb4 by user jamiereecebowman@gmail.com
2019-05-26T17:32:30.754494+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-05-26T17:32:30.769230+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2019-05-26T17:32:30.777197+00:00 app[web.1]: === puma shutdown: 2019-05-26 17:32:30 +0000 ===
2019-05-26T17:32:30.777233+00:00 app[web.1]: - Goodbye!
2019-05-26T17:32:30.879200+00:00 heroku[web.1]: Process exited with status 143
2019-05-26T17:32:29.241973+00:00 app[api]: Release v8 created by user jamiereecebowman@gmail.com
2019-05-26T17:32:32.304474+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000}`
2019-05-26T17:32:31.000000+00:00 app[api]: Build succeeded
2019-05-26T17:32:35.524455+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-26T17:32:35.529654+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-26T17:32:35.463479+00:00 app[web.1]: Puma starting in single mode...
2019-05-26T17:32:35.463505+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
2019-05-26T17:32:35.463508+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-05-26T17:32:35.463515+00:00 app[web.1]: * Environment: production
2019-05-26T17:32:35.463516+00:00 app[web.1]: ERROR: No application configured, nothing to run
2019-05-26T17:32:35.508336+00:00 heroku[web.1]: Process exited with status 1
2019-05-26T17:32:37.964291+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000}`
2019-05-26T17:32:40.632053+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-26T17:32:40.607403+00:00 heroku[web.1]: Process exited with status 1
2019-05-26T17:32:40.537108+00:00 app[web.1]: Puma starting in single mode...
2019-05-26T17:32:40.537133+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
2019-05-26T17:32:40.537135+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-05-26T17:32:40.537137+00:00 app[web.1]: * Environment: production
2019-05-26T17:32:40.537141+00:00 app[web.1]: ERROR: No application configured, nothing to run
2019-05-26T17:32:51.669120+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=aef506be-47ba-45b5-bd86-30ddf7607392 fwd="82.16.157.125" dyno= connect= service= status=503 bytes= protocol=https
2019-05-26T17:33:07.414438+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=d1035d79-641e-4a5b-9f3f-34df7922ae36 fwd="82.16.157.125" dyno= connect= service= status=503 bytes= protocol=https
2019-05-26T17:33:43.000000+00:00 app[api]: Build started by user jamiereecebowman@gmail.com
2019-05-26T17:34:04.616866+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-26T17:34:04.087250+00:00 app[api]: Deploy d390eb36 by user jamiereecebowman@gmail.com
2019-05-26T17:34:04.087250+00:00 app[api]: Release v9 created by user jamiereecebowman@gmail.com
2019-05-26T17:34:06.000000+00:00 app[api]: Build succeeded
2019-05-26T17:34:06.855761+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2019-05-26T17:34:10.124794+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-26T17:34:10.042957+00:00 app[web.1]: Puma starting in single mode...
2019-05-26T17:34:10.042984+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
2019-05-26T17:34:10.042986+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-05-26T17:34:10.042988+00:00 app[web.1]: * Environment: production
2019-05-26T17:34:10.042989+00:00 app[web.1]: ERROR: No application configured, nothing to run
2019-05-26T17:34:10.109040+00:00 heroku[web.1]: Process exited with status 1
2019-05-26T17:34:18.638053+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=e33fbda0-dd5f-4367-857d-ab98e728a154 fwd="82.16.157.125" dyno= connect= service= status=503 bytes= protocol=https
2019-05-26T17:34:30.521564+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=ebbb8606-bd9f-4ac1-ab43-d99517932983 fwd="82.16.157.125" dyno= connect= service= status=503 bytes= protocol=https
2019-05-26T17:35:38.000000+00:00 app[api]: Build started by user jamiereecebowman@gmail.com
2019-05-26T17:35:59.112460+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-26T17:35:58.930577+00:00 app[api]: Deploy 4f35b36a by user jamiereecebowman@gmail.com
2019-05-26T17:35:58.930577+00:00 app[api]: Release v10 created by user jamiereecebowman@gmail.com
2019-05-26T17:36:01.092005+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2019-05-26T17:36:00.000000+00:00 app[api]: Build succeeded
2019-05-26T17:36:03.293676+00:00 heroku[web.1]: State changed from starting to up
2019-05-26T17:36:03.175406+00:00 app[web.1]: Puma starting in single mode...
2019-05-26T17:36:03.175435+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
2019-05-26T17:36:03.175437+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-05-26T17:36:03.175439+00:00 app[web.1]: * Environment: production
2019-05-26T17:36:03.207079+00:00 app[web.1]: * Listening on tcp://0.0.0.0:24764
2019-05-26T17:36:03.207184+00:00 app[web.1]: Use Ctrl-C to stop
2019-05-26T17:36:08.059156+00:00 heroku[router]: at=info method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=38f03cea-298d-4db7-87cb-93fdac0e9cc3 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2599 protocol=https
2019-05-26T17:36:08.277430+00:00 heroku[router]: at=info method=GET path="/press/assets/main.css" host=agile-savannah-64601.herokuapp.com request_id=7b385745-b12e-437b-a528-2a10e6664ac7 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:36:08.399942+00:00 heroku[router]: at=info method=GET path="/press/assets/minima-social-icons.svg" host=agile-savannah-64601.herokuapp.com request_id=e3eaebe3-8d73-491a-ac8e-41dff86e499f fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:36:08.507360+00:00 heroku[router]: at=info method=GET path="/press/assets/js/api.js" host=agile-savannah-64601.herokuapp.com request_id=7712ba9e-4c01-41ec-8bd9-3515aefa8a69 fwd="82.16.157.125" dyno=web.1 connect=1ms service=3ms status=200 bytes=2515 protocol=https
2019-05-26T17:39:37.000000+00:00 app[api]: Build started by user jamiereecebowman@gmail.com
2019-05-26T17:39:56.994293+00:00 app[api]: Deploy a0412f1b by user jamiereecebowman@gmail.com
2019-05-26T17:39:56.994293+00:00 app[api]: Release v11 created by user jamiereecebowman@gmail.com
2019-05-26T17:39:57.303615+00:00 heroku[web.1]: Restarting
2019-05-26T17:39:57.319627+00:00 heroku[web.1]: State changed from up to starting
2019-05-26T17:39:57.974487+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2019-05-26T17:39:57.975330+00:00 app[web.1]: === puma shutdown: 2019-05-26 17:39:57 +0000 ===
2019-05-26T17:39:57.975334+00:00 app[web.1]: - Goodbye!
2019-05-26T17:39:57.965915+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-05-26T17:39:58.031537+00:00 heroku[web.1]: Process exited with status 143
2019-05-26T17:39:58.000000+00:00 app[api]: Build succeeded
2019-05-26T17:40:00.490953+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2019-05-26T17:40:03.527639+00:00 app[web.1]: Puma starting in single mode...
2019-05-26T17:40:03.527660+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
2019-05-26T17:40:03.527662+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-05-26T17:40:03.527663+00:00 app[web.1]: * Environment: production
2019-05-26T17:40:03.555588+00:00 app[web.1]: * Listening on tcp://0.0.0.0:23862
2019-05-26T17:40:03.555681+00:00 app[web.1]: Use Ctrl-C to stop
2019-05-26T17:40:04.745842+00:00 heroku[web.1]: State changed from starting to up
2019-05-26T17:40:05.984802+00:00 heroku[router]: at=info method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=d07dec49-ff91-4eb2-8a57-7dda9e2e1603 fwd="82.16.157.125" dyno=web.1 connect=0ms service=6ms status=200 bytes=2599 protocol=https
2019-05-26T17:40:06.359408+00:00 heroku[router]: at=info method=GET path="/press/assets/main.css" host=agile-savannah-64601.herokuapp.com request_id=dcb4abef-7d78-4222-b0cf-7fb2cf3e66b7 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:06.594188+00:00 heroku[router]: at=info method=GET path="/press/assets/js/api.js" host=agile-savannah-64601.herokuapp.com request_id=da9580dd-9761-427e-801d-5fd2f519b68d fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:06.726848+00:00 heroku[router]: at=info method=GET path="/press/assets/minima-social-icons.svg" host=agile-savannah-64601.herokuapp.com request_id=bed103ca-af05-496f-8744-c7bab011f813 fwd="82.16.157.125" dyno=web.1 connect=0ms service=6ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:08.519403+00:00 heroku[router]: at=info method=GET path="/" host=agile-savannah-64601.herokuapp.com request_id=a1fbea82-4d72-4599-a773-7d63c4283b37 fwd="82.16.157.125" dyno=web.1 connect=0ms service=5ms status=304 bytes=86 protocol=https
2019-05-26T17:40:08.728325+00:00 heroku[router]: at=info method=GET path="/press/assets/main.css" host=agile-savannah-64601.herokuapp.com request_id=72312822-a741-429b-b574-a338d193b474 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:08.735372+00:00 heroku[router]: at=info method=GET path="/press/assets/js/api.js" host=agile-savannah-64601.herokuapp.com request_id=b9a41525-3e14-49f1-9ff3-926a7ad7d203 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:08.856527+00:00 heroku[router]: at=info method=GET path="/press/assets/minima-social-icons.svg" host=agile-savannah-64601.herokuapp.com request_id=ebda1193-5b84-4d35-a74e-0fb3f5899721 fwd="82.16.157.125" dyno=web.1 connect=0ms service=9ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:28.904517+00:00 heroku[router]: at=info method=GET path="/press/" host=agile-savannah-64601.herokuapp.com request_id=5c13fc9c-75ad-4041-9b44-ffea83fb40c8 fwd="82.16.157.125" dyno=web.1 connect=1ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:29.136252+00:00 heroku[router]: at=info method=GET path="/press/assets/js/api.js" host=agile-savannah-64601.herokuapp.com request_id=cce09e17-43c6-4ab0-ab2e-baac8a02f0e7 fwd="82.16.157.125" dyno=web.1 connect=0ms service=2ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:29.129678+00:00 heroku[router]: at=info method=GET path="/press/assets/main.css" host=agile-savannah-64601.herokuapp.com request_id=46ce797a-a7ae-4ad5-a04c-239216e0ec3e fwd="82.16.157.125" dyno=web.1 connect=1ms service=4ms status=200 bytes=2515 protocol=https
2019-05-26T17:40:29.131123+00:00 heroku[router]: at=info method=GET path="/press/assets/minima-social-icons.svg" host=agile-savannah-64601.herokuapp.com request_id=dfe14a52-ce07-4ec9-b8a0-5a4249e206f4 fwd="82.16.157.125" dyno=web.1 connect=0ms service=3ms status=200 bytes=2515 protocol=https

我可以看到main.css正在被加载,但是它不包含.scss文件中需要编译的规则。

我尝试使用rake assets:precompile,但在其他地方看不到。我见过类似的问题,但似乎都是针对Ruby on Rails的,而我正在使用Jekyll来构建我的网站。

0 个答案:

没有答案