Skip to content

Commit

Permalink
Fixes #37904 - move css from vendor to foreman
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga committed Oct 10, 2024
1 parent 9f02910 commit 558c54e
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/helpers/reactjs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 15 additions & 1 deletion config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
Expand All @@ -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',
Expand All @@ -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;
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions webpack/assets/javascripts/exportAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
21 changes: 21 additions & 0 deletions webpack/assets/javascripts/react_app/common/scss/mixins.scss
Original file line number Diff line number Diff line change
@@ -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';
22 changes: 22 additions & 0 deletions webpack/assets/javascripts/react_app/common/scss/vendor-core.scss
Original file line number Diff line number Diff line change
@@ -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';
23 changes: 21 additions & 2 deletions webpack/assets/javascripts/react_app/common/variables.scss
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "~@theforeman/vendor/scss/variables";
@import "../../../../common/variables";

@keyframes blink {
0% {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~@theforeman/vendor/scss/variables';
@import '../../common/variables.scss';

$caption_font_weight: 600;
$background_image: url('../LoginPage/background.svg');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~@theforeman/vendor/scss/variables';
@import '../../../common/variables.scss';

.bookmarks-dropdown-item {
word-break: break-word;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import "~@theforeman/vendor/scss/variables";
@import '../../common/colors.scss';
@import '../../common/variables.scss';

.ReactPasswordStrength {
.ReactPasswordStrength-input {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~@theforeman/vendor/scss/variables';
@import '../../common//variables.scss';

.autocomplete-search {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "~@theforeman/vendor/scss/variables";
@import "../../../../common/variables.scss";

$screen-md: 992px !default;
$screen-md-min: $screen-md !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 558c54e

Please sign in to comment.