rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
542 stars 97 forks source link

How does one `rake assetpack:build` assets to public folder in a Sinatra classic app? (Also: If precompiling is unnecessary, how to serve static assets with Apache?) #174

Open alancwoo opened 10 years ago

alancwoo commented 10 years ago

I was wondering how to build out my assets via rake assetpack:build if I am creating a classic app? I am unable to precompile the assets if I don't define APP_CLASS = 'App'.

Defining APP_CLASS = 'App' results in the error: NameError: uninitialized constant App

A further question I have is, the documentation mentions that precompiling is unnecessary. I was wondering then, how to ensure that these static assets will be served by Apache (or other web server) when deploying the app? Would it simply be a matter of reconfiguring AssetPack to serve from and build to the public directory instead of /App?

lpil commented 10 years ago

Have you tried this?

APP_CLASS = 'Sinatra::Application'
rstacruz commented 10 years ago

A further question I have is, the documentation mentions that precompiling is unnecessary. I was wondering then, how to ensure that these static assets will be served by Apache (or other web server) when deploying the app?

Precompiling is "unnecessary" because they're served dynamically by the Sinatra app. This isn't exactly always the most ideal thing, but it works on almost all setups (most notably Heroku). If you need Apache to serve the assets statically, add the precompilation step to your deployment process.