-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Compatibility with Webpack 5 #2802
Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
b634d67
Major packages bump
gauravtiwari bcde488
Major upgrade
gauravtiwari b4701ed
New automatic API
gauravtiwari e2ea63a
Automatic rules
gauravtiwari 1153bfb
Update configuration
gauravtiwari 4ad3419
Remove loader installs
gauravtiwari 3564dd5
Move plugins
gauravtiwari 7624056
Restructure
gauravtiwari e81793b
Remove old confis
gauravtiwari bcaa218
Update packages
gauravtiwari b6e54c1
Remove extract_css
gauravtiwari c23caff
Remove unwanted rules
gauravtiwari 4e4e779
Remove extra installers
gauravtiwari 6346111
Cleanup deps
gauravtiwari bd5713c
Merge master
gauravtiwari 16f73bc
Upgrade assets plugin and make things work
gauravtiwari 8f0c048
Make eslint happy
gauravtiwari 22aea22
Fix tests
gauravtiwari 86d3b86
Remove extra deps
gauravtiwari a1e3e54
Merge branch 'master' into automatic-rules
gauravtiwari 78da636
Upgrade to latest
gauravtiwari ac0f9f5
Update assets plugin
gauravtiwari 4af653b
Use assets key
gauravtiwari 09fdf0d
Use loader objectt
gauravtiwari 33840e6
Update mini css extract plugin
gauravtiwari f7c9a95
Correct import
gauravtiwari 35e6b4d
Implementation is an object
gauravtiwari 2f08d6b
Remove file loader and use native assets
gauravtiwari c651b98
Use eslint prettier config
gauravtiwari a42deef
Cleanup rules
gauravtiwari 2f64b8f
Delete node modules loader
gauravtiwari 7d81bc4
Make mini data uri optional
gauravtiwari 12ddd48
Make postcss optional
gauravtiwari 41f5bc8
Make dev server available by default
gauravtiwari 9cb22c6
Actually not a great idea
gauravtiwari 3d541f3
Support Avif and webp
gauravtiwari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,9 @@ def current_webpacker_instance | |
# | ||
# Example: | ||
# | ||
# # When extract_css is false in webpacker.yml and the file is a css: | ||
# <%= asset_pack_path 'calendar.css' %> # => nil | ||
# | ||
# # When extract_css is true in webpacker.yml or the file is not a css: | ||
# <%= asset_pack_path 'calendar.css' %> # => "/packs/calendar-1016838bab065ae1e122.css" | ||
def asset_pack_path(name, **options) | ||
if current_webpacker_instance.config.extract_css? || !stylesheet?(name) | ||
if !stylesheet?(name) | ||
path_to_asset(current_webpacker_instance.manifest.lookup!(name), options) | ||
end | ||
end | ||
|
@@ -29,13 +25,9 @@ def asset_pack_path(name, **options) | |
# | ||
# Example: | ||
# | ||
# # When extract_css is false in webpacker.yml and the file is a css: | ||
# <%= asset_pack_url 'calendar.css' %> # => nil | ||
# | ||
# # When extract_css is true in webpacker.yml or the file is not a css: | ||
# <%= asset_pack_url 'calendar.css' %> # => "http://example.com/packs/calendar-1016838bab065ae1e122.css" | ||
def asset_pack_url(name, **options) | ||
if current_webpacker_instance.config.extract_css? || !stylesheet?(name) | ||
if !stylesheet?(name) | ||
url_to_asset(current_webpacker_instance.manifest.lookup!(name), options) | ||
end | ||
end | ||
|
@@ -148,17 +140,10 @@ def preload_pack_asset(name, **options) | |
# | ||
# Examples: | ||
# | ||
# # When extract_css is false in webpacker.yml: | ||
# <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # => | ||
# nil | ||
# | ||
# # When extract_css is true in webpacker.yml: | ||
# <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # => | ||
# <link rel="stylesheet" media="screen" href="/packs/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" /> | ||
def stylesheet_pack_tag(*names, **options) | ||
if current_webpacker_instance.config.extract_css? | ||
stylesheet_link_tag(*sources_from_manifest_entries(names, type: :stylesheet), **options) | ||
end | ||
stylesheet_link_tag(*sources_from_manifest_entries(names, type: :stylesheet), **options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gauravtiwari @rossta why was this removed? If one is using HMR with React, we don't want to extract the CSS. We want the CSS to come from the JS files so that it can be dynamically loaded in the browser. |
||
end | ||
|
||
# Creates link tags that reference the css chunks from entrypoints when using split chunks API, | ||
|
@@ -183,9 +168,7 @@ def stylesheet_pack_tag(*names, **options) | |
# <%= stylesheet_packs_with_chunks_tag 'calendar' %> | ||
# <%= stylesheet_packs_with_chunks_tag 'map' %> | ||
def stylesheet_packs_with_chunks_tag(*names, **options) | ||
if current_webpacker_instance.config.extract_css? | ||
stylesheet_link_tag(*sources_from_manifest_entrypoints(names, type: :stylesheet), **options) | ||
end | ||
stylesheet_link_tag(*sources_from_manifest_entrypoints(names, type: :stylesheet), **options) | ||
end | ||
|
||
private | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gauravtiwari
should it be
loaders.get('moduleSass').use
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pustovalov Hey, I think we need to overhaul the documentation. The class-based API is removed in 6.x
I will work on updating docs.