Class: Glslkit::Rails::Compiler
- Inherits:
-
Propshaft::Compiler
- Object
- Propshaft::Compiler
- Glslkit::Rails::Compiler
- Defined in:
- lib/glslkit/rails/compiler.rb
Overview
x-shader/x-vertex, x-shader/x-fragment, text/plain (§4.1) の3つに 登録される。前者2つは我々専用だが、text/plainはPropshaftが配信しうる 他のあらゆるプレーンテキストアセットと共有される — Propshaftはcompiler の登録をcontent_typeで紐付ける(拡張子ではない)ため、これが無いと このcompilerが無関係なtext/plainアセットにまで作用してしまう。 以下の拡張子ガードがそれを防いでいる。
Constant Summary collapse
- RELEVANT_EXTENSIONS =
%w[.glsl .vert .frag].freeze
Instance Method Summary collapse
Instance Method Details
#compile(asset, input) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/glslkit/rails/compiler.rb', line 17 def compile(asset, input) return input unless relevant?(asset) source = preprocess(asset) minify? ? Glslkit::Minifier.minify(source.code) : source.code end |
#referenced_by(asset) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/glslkit/rails/compiler.rb', line 24 def referenced_by(asset) return Set.new unless relevant?(asset) source = preprocess(asset) source.source_map.files.drop(1).filter_map { |path| load_path.find(path) }.to_set end |