Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for v2: Simplified configuration #9

Merged
merged 13 commits into from
May 23, 2017
Merged

Updates for v2: Simplified configuration #9

merged 13 commits into from
May 23, 2017

Conversation

justin808
Copy link
Member

@justin808 justin808 commented May 17, 2017

This change is Reviewable

@justin808
Copy link
Member Author

@kaizencodes @robwise @Conturbo please review.

@@ -17,7 +17,7 @@ def hot_loading?
end

def file_path
Rails.root.join("config", "webpack", "paths.yml")
Rails.root.join("config", "webpacker_lite.yml")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, the same code is used in configuration.rb. Might be worth having it dried.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

#
# # In production mode:
# <%= javascript_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
# <script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
# <script src="/public/webpack/production/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
def javascript_pack_tag(name, **options)
javascript_include_tag(WebpackerLite::Manifest.lookup("#{name}#{compute_asset_extname(name, type: :javascript)}"), **options)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to read, I'd consider extracting a method or two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

asset_type = WebpackerLite::Env.hot_loading? ? :hot : :static
names = Array(kwargs[asset_type])
manifested_names += get_manifests(names)
return "" if WebpackerLite::Env.hot_loading? && !kwargs[enabled_when_hot_loading].presence

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like enabled_when_hot_loading might need to be a symbol.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the tests didn't catch it? Might be worth adding a test to cover that.

end

def test_stylesheet_pack_tag
style = %(<link rel="stylesheet" media="screen" href="/webpack/bootstrap-c38deda30895059837cf.css" />)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd get rid of the variable style and just put the literal on 2nd line. If you want to keep it, I'd call it expected_style or something like that.

end

def test_lookup_success
asset_file = "bootstrap.js"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, a variable in these tests is a literal that the result of the tested method is compared to. In this case, it's the literal of the tested method's argument. Breaks expectations.

@justin808 justin808 changed the title Updated README, config, and APIs Updates for v1.1: README, config, and APIs May 17, 2017
@justin808
Copy link
Member Author

Hey! big question for @alexfedoseev @robwise @Judahmeek regarding hot reloading and webpacker_lite.

Should webpacker_lite be putting in the value of the hot reloading server host:port as part of the rails helper, or depending on the configuration of that from the manifest.json and requiring the setting of the publicPath in both the webpack output and manifest plugin setup.

My gut tells me that it’s better to keep the webpack manifest simpler so it’s really the mapping of output names to possibly fingerprinted filenames.

@justin808 justin808 changed the title Updates for v1.1: README, config, and APIs Updates for v2: Simplified configuration May 23, 2017
@justin808 justin808 merged commit d5c4839 into master May 23, 2017
@justin808 justin808 deleted the change-config branch May 23, 2017 19:30
dpuscher pushed a commit to dpuscher/webpacker_lite that referenced this pull request May 24, 2017
2.0.0 - 2017-05-23

* Rewrote README.md.
* Configuration is simplified and changed to a single file, /config/webpacker_lite.yml. 
   See README.md.
* v1 assumed that manifest.json would contain the host name for hot reloading.
   v2 puts in the host at the Ruby level.
* stylesheet_pack_tag API changed. ENV value for HOT_RELOADING == "TRUE"
  results in the stylesheet_pack_tag not writing anything due to hot reloading
  requiring inlined JavaScript of * styles and not extracted CSS.
* Removed any bits of JavaScript from webpacker_lite.
* Added tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants