lib/sewing_kit/webpack/helper.rb in sewing_kit-0.5.4 vs lib/sewing_kit/webpack/helper.rb in sewing_kit-0.5.5

- old
+ new

@@ -5,15 +5,18 @@ module SewingKit module Webpack module Helper include ActionView::Helpers + class UnknownJavaScriptAssetError < StandardError + end + def sewing_kit_asset_paths(source, extension: 'js') return '' unless source.present? + return '' if ['runtime', 'vendor'].include?(source) && !Rails.env.production? paths = SewingKit::Webpack::Manifest.asset_paths(source) - return '' unless paths[extension] [paths[extension]].flatten.reject { |path| path =~ /.*\.map$/ } end @@ -31,9 +34,14 @@ def sewing_kit_script_tag(*paths) options = paths.extract_options! tags = paths.uniq.map { |path| + if path == '' + next '' unless Rails.env.production? + raise UnknownJavaScriptAssetError.new('Empty JavaSscript path passed to sewing_kit') + end + create_asset_tag(:script, path, options) } safe_join(tags, "\n") end