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

fixup build process to better support front-end packages #6

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
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