lib/sewing_kit/webpack/helper.rb in sewing_kit-0.6.2 vs lib/sewing_kit/webpack/helper.rb in sewing_kit-0.7.0

- old
+ new

@@ -8,39 +8,39 @@ include ActionView::Helpers class UnknownJavaScriptAssetError < StandardError end - def sewing_kit_asset_paths(source, extension: 'js') - return '' unless source.present? - return '/webpack/assets/dll/vendor.js' if serve_development_asests? && 'vendor' == source && extension == 'js' + def sewing_kit_asset_paths(entrypointName, extension: 'js') + return '' unless entrypointName.present? - paths = SewingKit::Webpack::Manifest.asset_paths(source) - return '' unless paths[extension] + paths = SewingKit::Webpack::Manifest.asset_paths(entrypointName) + return '' unless paths && paths[extension] - [paths[extension]].flatten.reject { |path| path =~ /.*\.map$/ } + entryPaths = paths[extension] + if serve_development_assets? && extension == 'js' + entryPaths.unshift('/webpack/assets/dll/vendor.js') + end + entryPaths end def sewing_kit_link_tag(*paths) - return '' unless serve_compiled_assets? - options = paths.extract_options! tags = paths.uniq.map { |path| + next '' if path == '' create_asset_tag(:link, path, options) } safe_join(tags, "\n") end def sewing_kit_script_tag(*paths) options = paths.extract_options! tags = paths.uniq.map { |path| - if path == '' - next '' - end + next '' if path == '' create_asset_tag(:script, path, options) } safe_join(tags, "\n") @@ -77,15 +77,11 @@ # Consumes sewing-kit's [name]-[chunkhash].[ext] format return unless path =~ /.*-[A-Za-z0-9]{64}\.(js|css)/ path.rpartition('-').last.split('.').first end - def serve_compiled_assets? - Rails.env.production? || ENV['SK_SIMULATE_PRODUCTION'] == '1' - end - - def serve_development_asests? - return false if serve_compiled_assets? + def serve_development_assets? + return false if ENV['SK_SIMULATE_PRODUCTION'] == '1' Rails.env.development? end end end end