gpt4 book ai didi

css - Sinatra Assets 管道 - 不能使用链接到预编译的 css

转载 作者:太空宇宙 更新时间:2023-11-03 17:52:02 24 4
gpt4 key购买 nike

此处引用 https://github.com/kalasjocke/sinatra-asset-pipeline/issues/42

你好,

我不能让它在生产中工作,而它在开发中工作正常

当我在生产中部署时,它会进行预编译,但不会加载 CSS。JS 加载正常,但没有 CSS。因此我有一个带有一些 JS 的 html 页面,但没有图像,没有 CSS。

我的 Assets 是这样组织的:

capture d ecran 2014-11-26 a 15 12 42

在本地开发环境中, Assets 在 public/assets/中预编译(使用 rake assets:precompile) capture d ecran 2014-11-26 a 15 15 59

在 Prod env 中,capistrano 任务是这样配置的:

  after 'deploy:finishing', :finalize_update do
on roles(:web), in: :sequence do
execute(:chmod, '-R g+w', release_path) if fetch(:group_writable, true)

within release_path do
execute :rake, "assets:precompile RACK_ENV=production"
execute :rake, "assets:clean RACK_ENV=production"
end
end
end

Sinatra 应用程序(比如 myapp.rb)

# encoding: utf-8
require 'sinatra'
require 'haml'
require 'sass'
require 'compass'
require 'bootstrap-sass'
require 'sinatra/asset_pipeline'

Bundler.require

class MyApp < Sinatra::Base
set :assets_prefix, %w(assets vendor/assets)
set :assets_precompile, %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff)
register Sinatra::AssetPipeline

...

应用.css

*= require application

应用程序.scss

@import "bootstrap/variables";
@import "bootstrap/mixins";
...
...
@import "layout";

布局:

%link{ href: '/assets/application.css', rel: 'stylesheet' }

...

%script{ src:'//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'}
%script{ src: '//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js' }
%script{ src: '/assets/app.js' }

雷克文件:

require 'sinatra/asset_pipeline/task'
require './lib/myapp'
Sinatra::AssetPipeline::Task.define! Novagile

我是否遗漏了一些简单明了的东西,或者这是一个恶意的配置技巧? :'(

最佳答案

很难说到底出了什么问题。绝对是您的布局或 View 的来源。请看working example .我只能猜测,您必须自己处理环境(productiondevelopment)。我上面的例子是 view helper , 你可能会感兴趣。

关于css - Sinatra Assets 管道 - 不能使用链接到预编译的 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27152533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com