Roda - Assets duplicating every time I save

117 Views Asked by At

I'm building a very simple app in Roda and for some reason every time I save a css or js file it is compiling the assets and creating a duplication in the public assets folder. I have about 20 of the same css and js file but each with a different asset precompile prefix. Here is the code:

require 'roda'
require_relative './app'

class App < Roda
  plugin :render
  plugin :assets, css: 'style.scss', js: 'app.js'
  compile_assets

  route do |r|
    r.assets

    r.root do
      view 'app'
    end
  end
end

The app server is running with rerun, I don't know if that's relevant.

Any ideas?

1

There are 1 best solutions below

0
On

Assets plugin relies on SHA digest to name the compiled assets to allow for subresource integrity checks. Every time you make a change in your app.js file, the digest will change, so the new file name is generated.

You can disable it by setting sri option to nil in the plugin method call:

class App < Roda
  plugin :assets, css: 'style.scss', js: 'app.js', sri: nil
end

In production you probably want to leave SRI on. Especially if you plan on using a CDN.