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

KOGITO-2512: Setup patternfly-base to be used as dependency #190

Merged
merged 2 commits into from
Jun 24, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"@kogito-tooling/chrome-extension": "0.5.2",
"@kogito-tooling/kie-bc-editors": "0.5.2",
"@kogito-tooling/microeditor-envelope": "0.5.2",
"@kogito-tooling/microeditor-envelope-protocol": "0.5.2"
"@kogito-tooling/microeditor-envelope-protocol": "0.5.2",
"@kogito-tooling/patternfly-base": "0.5.2"
},
"scripts": {
"lint": "tslint -c ../../tslint.json 'src/**/*.{ts,tsx,js,jsx}'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const ZipPlugin = require("zip-webpack-plugin");
const packageJson = require("./package.json");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

function getLatestGitTag() {
const tagName = require("child_process")
Expand Down Expand Up @@ -153,7 +153,7 @@ module.exports = async (env, argv) => {
exclude: /node_modules/,
use: ["babel-loader"]
},
...envelope.patternflyLoaders
...pfWebpackUtils.patternflyLoaders
]
},
resolve: {
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

const commonConfig = {
mode: "development",
Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = [
entry: {
"webview/index": "./src/webview/index.tsx"
},
module: { rules: [...commonConfig.module.rules, ...envelope.patternflyLoaders] },
module: { rules: [...commonConfig.module.rules, ...pfWebpackUtils.patternflyLoaders] },
plugins: [
new CopyPlugin([
{ from: "./static/samples", to: "./samples" },
Expand Down
3 changes: 2 additions & 1 deletion packages/embedded-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"@kogito-tooling/core-api": "0.5.2",
"@kogito-tooling/kie-bc-editors": "0.5.2",
"@kogito-tooling/microeditor-envelope": "0.5.2",
"@kogito-tooling/microeditor-envelope-protocol": "0.5.2"
"@kogito-tooling/microeditor-envelope-protocol": "0.5.2",
"@kogito-tooling/patternfly-base": "0.5.2"
},
"scripts": {
"lint": "tslint -c ../../tslint.json 'src/**/*.{ts,tsx,js,jsx}'",
Expand Down
4 changes: 2 additions & 2 deletions packages/embedded-editor/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const CopyPlugin = require("copy-webpack-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

const commonConfig = {
mode: "development",
Expand All @@ -41,7 +41,7 @@ const commonConfig = {
exclude: /node_modules/,
use: ["babel-loader"]
},
...envelope.patternflyLoaders
...pfWebpackUtils.patternflyLoaders
]
},
resolve: {
Expand Down
4 changes: 2 additions & 2 deletions packages/hub/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");
const packageJson = require("./package.json");
const os = require("os");

Expand Down Expand Up @@ -110,7 +110,7 @@ module.exports = [
"webview/index": "./src/webview/index.tsx"
},
module: {
rules: [...commonConfig.module.rules, ...envelope.patternflyLoaders]
rules: [...commonConfig.module.rules, ...pfWebpackUtils.patternflyLoaders]
},
plugins: [new CopyPlugin([{ from: "static/index.html" }])]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/microeditor-envelope/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

module.exports = {
mode: "development",
Expand Down Expand Up @@ -57,7 +57,7 @@ module.exports = {
exclude: /node_modules/,
use: ["babel-loader"]
},
...envelope.patternflyLoaders
...pfWebpackUtils.patternflyLoaders
]
},
resolve: {
Expand Down
4 changes: 2 additions & 2 deletions packages/online-editor/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

function getLatestGitTag() {
const tagName = require("child_process")
Expand Down Expand Up @@ -117,7 +117,7 @@ module.exports = async (env, argv) => {
]
}
},
...envelope.patternflyLoaders
...pfWebpackUtils.patternflyLoaders
]
},
devServer: {
Expand Down
2 changes: 1 addition & 1 deletion packages/patternfly-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"license": "Apache-2.0",
"files": [
"dist"
"webpackUtils.js"
],
"repository": {
"type": "git",
Expand Down
34 changes: 22 additions & 12 deletions packages/patternfly-base/webpackUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
const path = require("path");
const BG_IMAGES_DIRNAME = "bgimages";

/**
* Two scenarios for nodeModulesDir:
* (1) When using @kogito-tooling/patternfly-base library as dependency for other projects,
* __dirname is already on node_modules folder.
* (2) When developing for kogito-tooling,
* patternfly-base is accessed directly so nodeModulesDir needs node_modules appended.
*/
const nodeModulesDir = "../.." + (__dirname.includes("node_modules") ? "" : "/node_modules");

module.exports = {
patternflyLoaders: [
{
Expand All @@ -32,11 +41,11 @@ module.exports = {
// only process modules with this loader
// if they live under a 'fonts' or 'pficon' directory
include: [
path.resolve(__dirname, "../../node_modules/patternfly/dist/fonts"),
path.resolve(__dirname, "../../node_modules/@patternfly/react-core/dist/styles/assets/fonts"),
path.resolve(__dirname, "../../node_modules/@patternfly/react-core/dist/styles/assets/pficon"),
path.resolve(__dirname, "../../node_modules/@patternfly/patternfly/assets/fonts"),
path.resolve(__dirname, "../../node_modules/@patternfly/patternfly/assets/pficon")
path.resolve(__dirname, nodeModulesDir + "/patternfly/dist/fonts"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/react-core/dist/styles/assets/fonts"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/react-core/dist/styles/assets/pficon"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/patternfly/assets/fonts"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/patternfly/assets/pficon")
],
use: {
loader: "file-loader",
Expand Down Expand Up @@ -90,21 +99,22 @@ module.exports = {
test: /\.(jpg|jpeg|png|gif)$/i,
include: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "../../node_modules/patternfly"),
path.resolve(__dirname, "../../node_modules/@patternfly/patternfly/assets/images"),
path.resolve(__dirname, "../../node_modules/@patternfly/react-styles/css/assets/images"),
path.resolve(__dirname, "../../node_modules/@patternfly/react-core/dist/styles/assets/images"),
path.resolve(__dirname, nodeModulesDir + "/patternfly"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/patternfly/assets/images"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/react-styles/css/assets/images"),
path.resolve(__dirname, nodeModulesDir + "/@patternfly/react-core/dist/styles/assets/images"),
path.resolve(
__dirname,
"../../node_modules/@patternfly/react-core/node_modules/@patternfly/react-styles/css/assets/images"
nodeModulesDir + "/@patternfly/react-core/node_modules/@patternfly/react-styles/css/assets/images"
),
path.resolve(
__dirname,
"../../node_modules/@patternfly/react-table/node_modules/@patternfly/react-styles/css/assets/images"
nodeModulesDir + "/@patternfly/react-table/node_modules/@patternfly/react-styles/css/assets/images"
),
path.resolve(
__dirname,
"../../node_modules/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css/assets/images"
nodeModulesDir +
"/@patternfly/react-inline-edit-extension/node_modules/@patternfly/react-styles/css/assets/images"
)
],
use: [
Expand Down
4 changes: 2 additions & 2 deletions packages/pmml-editor/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

module.exports = async (env, argv) => {
return {
Expand Down Expand Up @@ -57,7 +57,7 @@ module.exports = async (env, argv) => {
exclude: /node_modules/,
use: ["babel-loader"]
},
...envelope.patternflyLoaders
...pfWebpackUtils.patternflyLoaders
]
},
devServer: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@kogito-tooling/kie-bc-editors-unpacked": "0.5.2",
"@kogito-tooling/microeditor-envelope": "0.5.2",
"@kogito-tooling/microeditor-envelope-protocol": "0.5.2",
"@kogito-tooling/vscode-extension": "0.5.2"
"@kogito-tooling/vscode-extension": "0.5.2",
"@kogito-tooling/patternfly-base": "0.5.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const path = require("path");
const CircularDependencyPlugin = require("circular-dependency-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const envelope = require("../patternfly-base/webpackUtils");
const pfWebpackUtils = require("@kogito-tooling/patternfly-base/webpackUtils");

const commonConfig = {
mode: "development",
Expand Down Expand Up @@ -77,7 +77,7 @@ module.exports = [
"webview/index": "./src/webview/index.ts"
},
module: {
rules: [...commonConfig.module.rules, ...envelope.patternflyLoaders]
rules: [...commonConfig.module.rules, ...pfWebpackUtils.patternflyLoaders]
},
plugins: [
new CopyWebpackPlugin([
Expand Down