diff --git a/app/helpers/reactjs_helper.rb b/app/helpers/reactjs_helper.rb index a09381c2372..7c8425f5b28 100644 --- a/app/helpers/reactjs_helper.rb +++ b/app/helpers/reactjs_helper.rb @@ -42,7 +42,7 @@ def get_webpack_foreman_vendor_js end def get_webpack_foreman_vendor_css - foreman_vendor_css = get_webpack_chunk('foreman-vendor', 'css') + foreman_vendor_css = get_webpack_chunk('vendorStyles', 'css') stylesheet_link_tag("/webpack/#{foreman_vendor_css}") end diff --git a/config/webpack.config.js b/config/webpack.config.js index 17c8186432e..cd249d34914 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -14,6 +14,7 @@ const { ModuleFederationPlugin } = require('webpack').container; var pluginUtils = require('../script/plugin_webpack_directories'); var { generateExportsFile }= require('../webpack/assets/javascripts/exportAll'); var CompressionPlugin = require('compression-webpack-plugin'); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); class AddRuntimeRequirement { // to avoid "webpackRequire.l is not a function" error @@ -166,7 +167,8 @@ const coreConfig = function() { __dirname, '..', 'webpack/assets/javascripts/all_react_app_exports.js' - ), + ), + vendorStyles: path.join(__dirname, '..', 'webpack/assets/javascripts/react_app/common/scss/vendor-core.scss'), }; config.output = { path: path.join(__dirname, '..', 'public', 'webpack'), @@ -189,10 +191,14 @@ const coreConfig = function() { filename: manifestFilename, }) ); + plugins.push( + new MiniCssExtractPlugin() + ); config.plugins = plugins; var rules = config.module.rules; rules.push({ test: /\.(sa|sc|c)ss$/, + exclude: /vendor-core/i, use: [ { loader: 'style-loader', @@ -205,6 +211,14 @@ const coreConfig = function() { 'sass-loader', ], }); + rules.push({ + test: /vendor-core/i, + use: [ + MiniCssExtractPlugin.loader, + 'css-loader', + 'sass-loader', + ], + }); config.module.rules = rules; return config; }; diff --git a/package.json b/package.json index 7ae5676471f..e850c6c246e 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "eslint": "^6.7.2", "eslint-plugin-spellcheck": "0.0.17", "graphql": "^15.5.0", + "mini-css-extract-plugin": "^2.9.1", "path-browserify": "^1.0.1", "prettier": "^1.19.1", "pretty-format": "26.6.2", diff --git a/webpack/assets/javascripts/exportAll.js b/webpack/assets/javascripts/exportAll.js index d56a6497401..feb2aaa33ae 100644 --- a/webpack/assets/javascripts/exportAll.js +++ b/webpack/assets/javascripts/exportAll.js @@ -19,6 +19,7 @@ function generateExports(directoryPath, exportFileContent = '') { !dirent.name.endsWith('.test.js') && !dirent.name.endsWith('.fixtures.js') && !dirent.name.endsWith('mockRequests.js') && + !dirent.name.endsWith('vendor-core.scss') && !fileNameWithoutExtension.includes('TestHelper') && !fileNameWithoutExtension.includes('testHelper') && !fileNameWithoutExtension.includes('APITestSetup') diff --git a/webpack/assets/javascripts/react_app/common/scss/mixins.scss b/webpack/assets/javascripts/react_app/common/scss/mixins.scss new file mode 100644 index 00000000000..f106521f856 --- /dev/null +++ b/webpack/assets/javascripts/react_app/common/scss/mixins.scss @@ -0,0 +1,21 @@ +// Mixins - Bootstrap overrides +// ------------------- +@mixin box-shadow($shadow...) { + -webkit-box-shadow: $shadow; // iOS <4.3 & Android <4.1 + box-shadow: $shadow; +} + +// Form control outline +@mixin form-control-outline($color: $input-border-focus){ + $color-rgba: rgba(red($color), green($color), blue($color), .6); + &:focus { + border-color: $color; + outline: 0 !important; + @include box-shadow(unquote("inset 0 1px 1px rgba(3, 3, 3, 0.075), 0 0 8px #{$color-rgba}")); + } +} +/** + Third Party mixins imports here +*/ +@import '~patternfly/dist/sass/patternfly/bootstrap-mixin-overrides'; +@import '~patternfly/dist/sass/patternfly/mixins'; diff --git a/webpack/assets/javascripts/react_app/common/scss/vendor-core.scss b/webpack/assets/javascripts/react_app/common/scss/vendor-core.scss new file mode 100644 index 00000000000..c8a002e89d3 --- /dev/null +++ b/webpack/assets/javascripts/react_app/common/scss/vendor-core.scss @@ -0,0 +1,22 @@ +/** + Third Party libraries imports here +*/ +@import '../variables'; +@import './mixins'; + +@import '~multiselect/css/multi-select.css'; +@import '~react-diff-view/style/index.css'; +@import '~select2/select2-bootstrap.css'; +@import '~select2/select2.css'; +@import "~dsmorse-gridster/dist/jquery.gridster"; +@import "~datatables.net-bs/css/dataTables.bootstrap.css"; +@import "~@redhat-cloud-services/frontend-components/index.css"; + +// patternfly v3 +@import '~patternfly-react/dist/sass/_patternfly-react.scss'; +@import '~patternfly-react-extensions/dist/sass/_select.scss'; +@import '~patternfly/dist/sass/patternfly/_loading-state'; + +// patternfly v4 +@import '~@patternfly/patternfly/patternfly'; +@import '~@patternfly/patternfly/patternfly-addons'; diff --git a/webpack/assets/javascripts/react_app/common/variables.scss b/webpack/assets/javascripts/react_app/common/variables.scss index f7485b1fc2b..37f34808fe3 100644 --- a/webpack/assets/javascripts/react_app/common/variables.scss +++ b/webpack/assets/javascripts/react_app/common/variables.scss @@ -1,3 +1,22 @@ -@import '~@theforeman/vendor/scss/variables.scss'; +/** + Third Party variables imports here +*/ +// patternfly v3 +$font-path: '~patternfly/dist/fonts/'; +$img-path: '~patternfly/dist/img/'; +$icon-font-path: '~patternfly/dist/fonts/'; -$header-max-width: calc(#{$pf-global--breakpoint--lg} + 70px); //TODO move into @theforeman/vendor/scss/variables +// patternfly v4 +$pf-global--font-path: '~@patternfly/patternfly/assets/fonts'; +$fa-font-path: '~@patternfly/patternfly/assets/fonts/webfonts'; +$pf-global--fonticon-path: '~@patternfly/patternfly/assets/pficon'; +$pf-global--image-path: '~@patternfly/patternfly/assets/images'; + +// patternfly v3 +@import '~bootstrap-sass/assets/stylesheets/bootstrap/variables'; +@import '~patternfly/dist/sass/patternfly/variables'; + +// patternfly v4 +@import '~@patternfly/patternfly/base/patternfly-variables'; + +$header-max-width: calc(#{$pf-global--breakpoint--lg} + 70px); diff --git a/webpack/assets/javascripts/react_app/components/Layout/components/ImpersonateIcon/ImpersonateIcon.scss b/webpack/assets/javascripts/react_app/components/Layout/components/ImpersonateIcon/ImpersonateIcon.scss index fee44434dbc..7b6b05a1fb1 100644 --- a/webpack/assets/javascripts/react_app/components/Layout/components/ImpersonateIcon/ImpersonateIcon.scss +++ b/webpack/assets/javascripts/react_app/components/Layout/components/ImpersonateIcon/ImpersonateIcon.scss @@ -1,4 +1,4 @@ -@import "~@theforeman/vendor/scss/variables"; +@import "../../../../common/variables"; @keyframes blink { 0% { diff --git a/webpack/assets/javascripts/react_app/components/Layout/components/TaxonomySwitcher/TaxonomyDropdown.scss b/webpack/assets/javascripts/react_app/components/Layout/components/TaxonomySwitcher/TaxonomyDropdown.scss index 5f7e814d201..2f8ea071f87 100644 --- a/webpack/assets/javascripts/react_app/components/Layout/components/TaxonomySwitcher/TaxonomyDropdown.scss +++ b/webpack/assets/javascripts/react_app/components/Layout/components/TaxonomySwitcher/TaxonomyDropdown.scss @@ -1,4 +1,4 @@ -@import '~@theforeman/vendor/scss/variables'; +@import '../../../../common/variables.scss'; .pf-c-masthead .pf-c-toolbar { .pf-c-context-selector__menu-search { diff --git a/webpack/assets/javascripts/react_app/components/LoginPage/LoginPage.scss b/webpack/assets/javascripts/react_app/components/LoginPage/LoginPage.scss index c0567e34b7c..5827565ddaa 100644 --- a/webpack/assets/javascripts/react_app/components/LoginPage/LoginPage.scss +++ b/webpack/assets/javascripts/react_app/components/LoginPage/LoginPage.scss @@ -1,4 +1,4 @@ -@import '~@theforeman/vendor/scss/variables'; +@import '../../common/variables.scss'; $caption_font_weight: 600; $background_image: url('../LoginPage/background.svg'); diff --git a/webpack/assets/javascripts/react_app/components/PF4/Bookmarks/bookmarks.scss b/webpack/assets/javascripts/react_app/components/PF4/Bookmarks/bookmarks.scss index b41b45aad74..5fdad1912c7 100644 --- a/webpack/assets/javascripts/react_app/components/PF4/Bookmarks/bookmarks.scss +++ b/webpack/assets/javascripts/react_app/components/PF4/Bookmarks/bookmarks.scss @@ -1,4 +1,4 @@ -@import '~@theforeman/vendor/scss/variables'; +@import '../../../common/variables.scss'; .bookmarks-dropdown-item { word-break: break-word; diff --git a/webpack/assets/javascripts/react_app/components/PasswordStrength/PasswordStrength.scss b/webpack/assets/javascripts/react_app/components/PasswordStrength/PasswordStrength.scss index db05e547a3c..a133d6176cf 100644 --- a/webpack/assets/javascripts/react_app/components/PasswordStrength/PasswordStrength.scss +++ b/webpack/assets/javascripts/react_app/components/PasswordStrength/PasswordStrength.scss @@ -1,5 +1,5 @@ -@import "~@theforeman/vendor/scss/variables"; @import '../../common/colors.scss'; +@import '../../common/variables.scss'; .ReactPasswordStrength { .ReactPasswordStrength-input { diff --git a/webpack/assets/javascripts/react_app/components/SearchBar/SearchBar.scss b/webpack/assets/javascripts/react_app/components/SearchBar/SearchBar.scss index 1d3c880ace0..9a82d5fa94b 100644 --- a/webpack/assets/javascripts/react_app/components/SearchBar/SearchBar.scss +++ b/webpack/assets/javascripts/react_app/components/SearchBar/SearchBar.scss @@ -1,4 +1,4 @@ -@import '~@theforeman/vendor/scss/variables'; +@import '../../common//variables.scss'; .autocomplete-search { width: 100%; diff --git a/webpack/assets/javascripts/react_app/components/common/forms/DateTime/DateTimeOverrides.scss b/webpack/assets/javascripts/react_app/components/common/forms/DateTime/DateTimeOverrides.scss index 31c6f3a6c93..4fd50975cce 100644 --- a/webpack/assets/javascripts/react_app/components/common/forms/DateTime/DateTimeOverrides.scss +++ b/webpack/assets/javascripts/react_app/components/common/forms/DateTime/DateTimeOverrides.scss @@ -1,4 +1,4 @@ -@import "~@theforeman/vendor/scss/variables"; +@import "../../../../common/variables.scss"; $screen-md: 992px !default; $screen-md-min: $screen-md !default; diff --git a/webpack/assets/javascripts/react_app/components/common/forms/NumericInput.scss b/webpack/assets/javascripts/react_app/components/common/forms/NumericInput.scss index 1e06824d4cd..305999c1489 100644 --- a/webpack/assets/javascripts/react_app/components/common/forms/NumericInput.scss +++ b/webpack/assets/javascripts/react_app/components/common/forms/NumericInput.scss @@ -1,5 +1,5 @@ -@import "~@theforeman/vendor/scss/variables"; -@import "~@theforeman/vendor/scss/mixins"; +@import "../../../common/variables"; +@import "../../../common/scss/mixins"; .foreman-numeric-input { position: relative;