Method: ArchitectureJS::Blueprint#compile_src_file

Defined in:
lib/architecture-js/blueprint.rb

#compile_src_file(file_path, file_name) ⇒ Object



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/architecture-js/blueprint.rb', line 161

def compile_src_file(file_path, file_name)
  sprockets = Sprockets::Secretary.new(
    root: ArchitectureJS::base_directory,
    asset_root: @config[:asset_root],
    load_path: ['repository'],
    source_files: [file_path],
    interpolate_constants: false
  )

  compiled_file = sprockets.concatenation
  message = File.exists?("#{@root}/#{@config[:build_dir]}/#{file_name}.js") ? "#{@config[:build_dir]}/#{file_name}.js updated" : "#{@config[:build_dir]}/#{file_name}.js created"
  compiled_file.save_to "#{@root}/#{@config[:build_dir]}/#{file_name}.js"
  ArchitectureJS::Notification.log message
  sprockets.install_assets

rescue Exception => error
  @errors = true
  puts ArchitectureJS::Notification.error "Sprockets error: #{error.message}"
  raise if @raise_errors
end