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

🐛 Fix packaging of fonts #2020

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 47 additions & 69 deletions client/config/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { brandingAssetPath } from "@konveyor-ui/common";
import { LANGUAGES_BY_FILE_EXTENSION } from "./monacoConstants";

const pathTo = (relativePath: string) => path.resolve(__dirname, relativePath);
const nodeModules = (pkg: string) => pathTo(`../../node_modules/${pkg}`);
const brandingPath = brandingAssetPath();
const manifestPath = path.resolve(brandingPath, "manifest.json");

Expand Down Expand Up @@ -37,65 +38,41 @@ const config: Configuration = {
},
},
},

// Ref: https://github.com/patternfly/patternfly-react-seed/blob/main/webpack.common.js
{
test: /\.(svg|ttf|eot|woff|woff2)$/,
type: "asset/resource",
// only process modules with this loader
// if they live under a 'fonts' or 'pficon' directory
include: [
pathTo("../../node_modules/patternfly/dist/fonts"),
pathTo(
"../../node_modules/@patternfly/react-core/dist/styles/assets/fonts"
),
pathTo(
"../../node_modules/@patternfly/react-core/dist/styles/assets/pficon"
),
pathTo("../../node_modules/@patternfly/patternfly/assets/fonts"),
pathTo("../../node_modules/@patternfly/patternfly/assets/pficon"),
nodeModules("patternfly/dist/fonts"),
nodeModules("@patternfly/react-core/dist/styles/assets/fonts"),
nodeModules("@patternfly/react-core/dist/styles/assets/pficon"),
nodeModules("@patternfly/patternfly/assets/fonts"),
nodeModules("@patternfly/patternfly/assets/pficon"),
],
use: {
loader: "file-loader",
options: {
// Limit at 50k. larger files emited into separate files
limit: 5000,
outputPath: "fonts",
name: "[name].[ext]",
},
},
},
{
test: /\.(xsd)$/,
include: [pathTo("../src")],
use: {
loader: "raw-loader",
options: {
esModule: true,
},
},
},
{
test: /\.svg$/,
type: "asset/inline",
include: (input) => input.indexOf("background-filter.svg") > 1,
use: [
{
loader: "url-loader",
options: {
limit: 5000,
outputPath: "svgs",
name: "[name].[ext]",
},
},
],
type: "javascript/auto",
},
{
test: /\.svg$/,
// only process SVG modules with this loader if they live under a 'bgimages' directory
// this is primarily useful when applying a CSS background using an SVG
include: (input) => input.indexOf(BG_IMAGES_DIRNAME) > -1,
use: {
loader: "svg-url-loader",
options: {},
},
type: "asset/inline",
},
{
test: /\.svg$/,
Expand All @@ -110,53 +87,32 @@ const config: Configuration = {
loader: "raw-loader",
options: {},
},
type: "javascript/auto",
},
{
test: /\.(jpg|jpeg|png|gif)$/i,
include: [
pathTo("../src"),
pathTo("../../node_modules/patternfly"),
pathTo("../../node_modules/@patternfly/patternfly/assets/images"),
pathTo(
"../../node_modules/@patternfly/react-styles/css/assets/images"
),
pathTo(
"../../node_modules/@patternfly/react-core/dist/styles/assets/images"
),
pathTo(
"../../node_modules/@patternfly/react-core/node_modules/@patternfly/react-styles/css/assets/images"
nodeModules("patternfly"),
nodeModules("@patternfly/patternfly/assets/images"),
nodeModules("@patternfly/react-styles/css/assets/images"),
nodeModules("@patternfly/react-core/dist/styles/assets/images"),
nodeModules(
"@patternfly/react-core/node_modules/@patternfly/react-styles/css/assets/images"
),
pathTo(
"../../node_modules/@patternfly/react-table/node_modules/@patternfly/react-styles/css/assets/images"
nodeModules(
"@patternfly/react-table/node_modules/@patternfly/react-styles/css/assets/images"
),
pathTo(
"../../node_modules/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css/assets/images"
nodeModules(
"@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css/assets/images"
),
],
use: [
{
loader: "url-loader",
options: {
limit: 5000,
outputPath: "images",
name: "[name].[ext]",
},
type: "asset",
parser: {
dataUrlCondition: {
maxSize: 8096,
},
],
type: "javascript/auto",
},
{
test: pathTo("../../node_modules/xmllint/xmllint.js"),
loader: "exports-loader",
options: {
exports: "xmllint",
},
},
{
test: /\.yaml$/,
use: "raw-loader",
},

// For monaco-editor-webpack-plugin --->
{
Expand All @@ -169,6 +125,28 @@ const config: Configuration = {
type: "asset/resource",
},
// <--- For monaco-editor-webpack-plugin

{
test: /\.(xsd)$/,
include: [pathTo("../src")],
use: {
loader: "raw-loader",
options: {
esModule: true,
},
},
},
{
test: nodeModules("xmllint/xmllint.js"),
loader: "exports-loader",
options: {
exports: "xmllint",
},
},
{
test: /\.yaml$/,
use: "raw-loader",
},
],
},

Expand Down
5 changes: 1 addition & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"analyze": "source-map-explorer 'dist/static/js/*.js'",
"clean": "rimraf ./dist",
"clean": "rimraf ./dist ./coverage",
"extract": "i18next --config i18next-parser.config.js",
"prebuild": "npm run clean && npm run tsc -- --noEmit",
"build": "NODE_ENV=production webpack --config ./config/webpack.prod.ts",
Expand Down Expand Up @@ -79,7 +79,6 @@
"css-minimizer-webpack-plugin": "^6.0.0",
"dotenv-webpack": "^8.1.0",
"exports-loader": "^3.1.0",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"html-webpack-plugin": "^5.6.0",
"i18next-parser": "^0.13.0",
Expand All @@ -91,11 +90,9 @@
"react-refresh-typescript": "^2.0.9",
"source-map-explorer": "^2.5.2",
"style-loader": "^3.3.4",
"svg-url-loader": "^8.0.0",
"terser-webpack-plugin": "^5.3.10",
"ts-loader": "^9.5.1",
"tsconfig-paths-webpack-plugin": "^4.0.0",
"url-loader": "^4.1.1",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.2",
Expand Down
65 changes: 0 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading