Skip to content

Commit

Permalink
Merge pull request #6 from spalger/pr/114129
Browse files Browse the repository at this point in the history
fixup build process to better support front-end packages
  • Loading branch information
Dosant authored Oct 12, 2021
2 parents 6ccb153 + e7e8119 commit ec391e2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
10 changes: 9 additions & 1 deletion packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ const IS_CODE_COVERAGE = !!process.env.CODE_COVERAGE;
const ISTANBUL_PRESET_PATH = require.resolve('@kbn/babel-preset/istanbul_preset');
const BABEL_PRESET_PATH = require.resolve('@kbn/babel-preset/webpack_preset');

const nodeModulesButNotKbnPackages = (path: string) => {
if (!path.includes('node_modules')) {
return false;
}

return !path.includes(`node_modules${Path.sep}@kbn${Path.sep}`);
};

export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker: WorkerConfig) {
const ENTRY_CREATOR = require.resolve('./entry_point_creator');

Expand Down Expand Up @@ -134,7 +142,7 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
},
{
test: /\.scss$/,
exclude: /node_modules/,
exclude: nodeModulesButNotKbnPackages,
oneOf: [
...worker.themeTags.map((theme) => ({
resourceQuery: `?${theme}`,
Expand Down
24 changes: 19 additions & 5 deletions packages/kbn-react-page-template/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
"types/**/*.ts"
"src/**/*.scss",
"src/**/*.svg",
],
exclude = [
"**/*.test.*",
Expand All @@ -26,7 +27,6 @@ filegroup(
)

NPM_MODULE_EXTRA_FILES = [
"react/package.json",
"package.json",
"README.md"
]
Expand All @@ -41,20 +41,34 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-babel-preset",
"//packages/kbn-i18n",
"@npm//tslib",
"@npm//@types/jest",
"@npm//@types/prop-types",
"@npm//@types/classnames",
"@npm//@types/react",
"@npm//@elastic/eui",
"//packages/kbn-i18n",
]

jsts_transpiler(
name = "target_node",
name = "target_webpack",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
additional_args = [
"--copy-files",
"--quiet"
],
)

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
additional_args = [
"--copy-files",
"--quiet"
],
)

ts_config(
Expand Down Expand Up @@ -83,7 +97,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node", ":target_webpack", ":tsc_types"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-react-page-template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@kbn/react-page-template",
"main": "./target_node/index.js",
"browser": "./target_webpack/index.js",
"types": "./target_types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
Expand Down
4 changes: 0 additions & 4 deletions packages/kbn-react-page-template/react/package.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/kbn-react-page-template/src/assets/texture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
line-height: 100px;
border-radius: 100px;
display: inline-block;
background: $euiColorEmptyShade url('../../assets/texture.svg') no-repeat;
background: $euiColorEmptyShade url('../assets/texture.svg') no-repeat;
background-size: cover, 125%;
text-align: center;
}
Expand Down

0 comments on commit ec391e2

Please sign in to comment.