-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3848 from 3scale/bye_bye_webpacker
🔥 Remove webpacker
- Loading branch information
Showing
109 changed files
with
2,851 additions
and
5,315 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# rubocop:disable Rails/HelperInstanceVariable | ||
# frozen_string_literal: false | ||
|
||
module WebpackHelper | ||
def load_webpack_manifest | ||
JSON.parse(File.read('public/packs/manifest.json')) | ||
rescue Errno::ENOENT | ||
raise "The webpack manifest file does not exist. Try running `rails assets:precompile`" | ||
end | ||
|
||
def webpack_manifest | ||
# Always get manifest.json on the fly in development mode | ||
return load_webpack_manifest if Rails.env.development? | ||
|
||
Rails.configuration.x.webpack.manifest ||= load_webpack_manifest | ||
end | ||
|
||
## | ||
# Returns a string of HTML script and style tags, containing all chunks of one or more +packs+. | ||
# Chunks generated from ".ts" packs are located under the entrypoint with extension. | ||
# Chunks generated from ".scss" packs are located under the entrypoint without extension. | ||
# | ||
# +packs+ is a list of pack names, without extension (.ts, .js). | ||
# | ||
# FIXME: the entrypoints in manifest should not have extension .ts | ||
# | ||
# A RuntimeError is raised if one pack is not found in the manifest, possibly pointing out a typo. | ||
# | ||
# ⚠️ This method smells of :reek:NestedIterators and :reek:TooManyStatements | ||
# | ||
def javascript_packs_with_chunks_tag(*packs) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity | ||
@packs ||= [] | ||
tags = '' | ||
entrypoints = webpack_manifest['entrypoints'] | ||
|
||
packs.each do |pack| | ||
entrypoint_with_extension = entrypoints["#{pack}.ts"] || {} | ||
entrypoint_without_extension = entrypoints[pack] || {} | ||
|
||
entrypoint = entrypoint_with_extension.deep_merge(entrypoint_without_extension) do |key, this_val, other_val| | ||
(this_val + other_val).uniq | ||
end | ||
raise "No entrypoint '#{pack}' in manifest" if entrypoint.empty? | ||
|
||
assets = entrypoint['assets'] | ||
|
||
if (js = assets['js']) | ||
new_js_assets = js - @packs | ||
@packs.concat(new_js_assets) | ||
tags.concat(javascript_include_tag(*new_js_assets, defer: false), "\n") | ||
end | ||
|
||
if (css = assets['css']) # rubocop:disable Style/Next | ||
new_css_assets = css - @packs | ||
@packs.concat(new_css_assets) | ||
tags.concat(stylesheet_link_tag(*new_css_assets, defer: false)) | ||
end | ||
end | ||
|
||
tags.html_safe # rubocop:disable Rails/OutputSafety | ||
end | ||
|
||
## | ||
# Returns a string of HTML style tags, containing all CSS chunks of one or more +packs+. | ||
# Chunks generated from ".scss" packs are located under the entrypoint without extension. | ||
# | ||
# +packs+ is a list of pack names, without extension. | ||
# | ||
# A RuntimeError is raised if one pack is not found in the manifest, possibly pointing out a typo. | ||
# | ||
# ⚠️ This method smells of :reek:TooManyStatements | ||
# | ||
def stylesheet_packs_chunks_tag(*packs) # rubocop:disable, Metrics/MethodLength, Metrics/CyclomaticComplexity | ||
@packs ||= [] | ||
tags = '' | ||
entrypoints = webpack_manifest['entrypoints'] | ||
|
||
packs.each do |pack| | ||
entrypoint = entrypoints[pack] || {} | ||
raise "No entrypoint '#{pack}' in manifest" if entrypoint.empty? | ||
|
||
assets = entrypoint['assets'] | ||
|
||
next unless (css = assets['css']) | ||
|
||
new_css_assets = css - @packs | ||
@packs.concat(new_css_assets) | ||
tags += stylesheet_link_tag(*new_css_assets, defer: false) | ||
end | ||
|
||
tags.html_safe # rubocop:disable Rails/OutputSafety | ||
end | ||
end | ||
|
||
# rubocop:enable Rails/HelperInstanceVariable |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import '~@patternfly/patternfly/components/DescriptionList/description-list.css'; | ||
@import '~@patternfly/patternfly/components/Table/table.css'; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import '~@patternfly/patternfly/components/Table/table.css'; | ||
@import '~@patternfly/patternfly/layouts/Grid/grid.css'; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import '~@patternfly/patternfly/layouts/Grid/grid.css'; | ||
@import '~@patternfly/patternfly/components/DescriptionList/description-list.css'; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import '~@patternfly/patternfly/components/Table/table.css'; | ||
@import '~@patternfly/patternfly/components/OverflowMenu/overflow-menu.css'; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Small snippet to handle opening/closing of overflow menu, since this page is pure HTML. | ||
document.addEventListener('DOMContentLoaded', () => { | ||
document.addEventListener('mouseup', () => { | ||
document.querySelectorAll<HTMLUListElement>('.pf-c-overflow-menu ul.pf-c-dropdown__menu') | ||
.forEach(menu => { | ||
menu.hidden = true | ||
}) | ||
}) | ||
|
||
document.querySelectorAll<HTMLButtonElement>('.pf-c-overflow-menu button.pf-c-dropdown__toggle') | ||
.forEach(toggle => { | ||
toggle.addEventListener('click', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const menu = toggle.nextElementSibling! as HTMLUListElement | ||
menu.hidden = !menu.hidden | ||
}) | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '~@patternfly/patternfly/components/EmptyState/empty-state.css'; |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Each PatternFly component already contains the CSS related to the component. In order to have | ||
// consistent styles throughout the application, PatternFly Base CSS should be used in the project, | ||
// or some components may diverge in appearance. This import statement should be placed before your | ||
// main application component is imported. | ||
// https://github.com/patternfly/patternfly-react/blob/main/packages/react-core/README.md | ||
|
||
@import '@patternfly/patternfly/patternfly-base.css'; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import '~@patternfly/patternfly/components/Button/button.css'; | ||
@import '~@patternfly/patternfly/components/Check/check.css'; | ||
@import '~@patternfly/patternfly/components/Form/form.css'; | ||
@import '~@patternfly/patternfly/components/FormControl/form-control.css'; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '~@patternfly/patternfly/components/Table/table.css'; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '~@patternfly/patternfly/components/DataList/data-list.css'; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '~@patternfly/patternfly/components/Table/table.css'; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import '~@patternfly/patternfly/components/Table/table.css'; | ||
@import '~@patternfly/patternfly/components/OverflowMenu/overflow-menu.css'; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
@import '~@patternfly/patternfly/components/Table/table.css'; |
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.