Rails 静态资源本地编译问题

rails_taotao · 2018年04月27日 · 539 次阅读

使用mina+unicorn部署本地编译静态资源 部署命令行

deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    # invoke :'sidekiq:quiet'
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'


    system "RAILS_ENV=production rails assets:precompile"
    system "rsync -cvzrltogD --progress #{fetch(:local_path)}/public/assets/ #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets/"

    # system "RAILS_ENV=production rails assets:precompile"
    # # command %[mkdir -p "#{fetch(:current_path)}/public/assets"]
    # system "a"



    # system "rsync -cvzrltogD --progress public/assets/* #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets/"
    # system "rm -rf public/assets"


    # invoke :'rails:assets_precompile'

    # rsync -cvzrltogD --progress public/stylesheets/* chuck@youtulink.com:/home/chuck/a15321/current/public/stylesheets

    # system "rsync -cvzrltogD --progress public/javascripts/* #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets"
    # system "rsync -cvzrltogD --progress public/stylesheets/* #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets"
    # system "rsync -cvzrltogD --progress public/fonts #{fetch(:user)}@#{fetch(:domain)}:#{fetch(:current_path)}/public/assets"

    invoke :'deploy:cleanup'

    on :launch do
      command "mkdir -p #{fetch(:current_path)}/tmp/"
      command "mkdir -p #{fetch(:current_path)}/tmp/logs"
      command "mkdir -p #{fetch(:current_path)}/tmp/pids"
      command "mkdir -p #{fetch(:current_path)}/tmp/sockets"
      command "touch #{fetch(:current_path)}/tmp/restart.txt"
      invoke :'unicorn:restart'
      # invoke :'sidekiq:restart'
    end

production.rb文件配置

config.assets.js_compressor = Uglifier.new(harmony: true)
config.public_file_server.enabled = true

本地编译会产生mainifese.json这个隐藏文件。必须将其同步到生产环境的public/aseets目录下。 这样就可以解决使用mina部署时线下编译静态资源。

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册