2016-01-13 109 views
0

我正在使用Middleman和activate :asset_hash選項,以便使用哈希編譯資源來強制高速緩存失效。問題是,我還加載一些HTML與角templateUrl模板是這樣的:Middleman asset_hash with Angular templateUrl

function($routeProvider) { 
    $routeProvider. 
     when('/dashboard', { 
      templateUrl: 'templates/dashboard.html', 
.... 

dashboard文件被用類似templates/dashboard-cc1554f0.html的哈希編譯等角度沒有找到該文件。

有沒有辦法在Angular文件中傳遞Middleman在構建時生成的相同散列?

回答

0

我必須告訴你,我沒有遇到這個問題(我的所有js,css和圖像都是散列的,但html文件沒有)。這是我的Gemfile

的Gemfile

# If you do not have OpenSSL installed, update 
# the following line to use "http://" instead 
source 'https://ruby.taobao.org' 

gem "middleman", "~>4.0.0" 

# Live-reloading plugin 
# gem "middleman-livereload", "~> 3.2.0" 

# For faster file watcher updates on Windows: 
gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] 

# Windows does not come with time zone data 
gem "tzinfo-data", platforms: [:mswin, :mingw, :jruby] 

gem "middleman-minify-html" 

gem "middleman-sprockets", "~> 4.0.0.rc" 

這裏是我的config.rb

config.rb

set :css_dir, 'css' 

set :js_dir, 'app' 

set :images_dir, 'images' 

set :layout, false 

# Build-specific configuration 
configure :development do 
    set :backend, 'http://localhost:3000' 
    set :frontend, 'http://localhost:4567/#' 
end 

configure :build do 
    set :backend, 'https://api.example.com' 
    set :frontend, 'https://www.example.com/#' 

    # For example, change the Compass output style for deployment 
    activate :minify_css 

    # Minify Javascript on build 
    activate :minify_javascript 

    # Minify HTML files on build, requires gem `middleman-minify-html` 
    activate :minify_html 

    # Enable cache buster 
    activate :asset_hash 

    # gzip text files 
    activate :gzip 
end 

你可以看到,我使用中間人4.0。

如果您的問題在升級中間人後仍然存在,也許您可​​以將您的js文件重命名爲xxx.js.erb並嘗試助手url_for

+0

我試圖'url_for'這樣的: '時( '/儀表板',{ templateUrl: '<%= url_for( 「模板/ dashboard.html」)%>'' 但它沒沒有考慮資產哈希值 – stilllife