Skip to content

Commit 29e02bf

Browse files
committed
build(ui-alerts,console): make documentation preview builds show console logs
INSTUI-4522
1 parent f5941b1 commit 29e02bf

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

.github/workflows/preview.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
- name: Build docs-app
2525
run: npm run build:docs
2626
if: github.event.action != 'closed'
27+
env:
28+
GITHUB_PULL_REQUEST_PREVIEW: 'true'
2729
- uses: rossjrw/pr-preview-action@v1
2830
with:
2931
source-dir: ./packages/__docs__/__build__

packages/__docs__/webpack.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ import { globbySync } from 'globby'
3030
import { merge } from 'webpack-merge'
3131
import { processSingleFile } from './lib/build-docs.mjs'
3232
import resolve from './resolve.mjs'
33+
import webpack from 'webpack'
3334

3435
const ENV = process.env.NODE_ENV || 'production'
3536
const DEBUG = process.env.DEBUG || ENV === 'development'
37+
const GITHUB_PULL_REQUEST_PREVIEW = process.env.GITHUB_PULL_REQUEST_PREVIEW || 'false'
3638

3739
const outputPath = resolvePath(import.meta.dirname, '__build__')
3840
const resolveAliases = DEBUG ? { resolve } : {}
@@ -79,6 +81,9 @@ const config = merge(baseConfig, {
7981
template: './src/index.html',
8082
chunks: ['main'],
8183
}),
84+
new webpack.DefinePlugin({
85+
'process.env.GITHUB_PULL_REQUEST_PREVIEW': JSON.stringify(GITHUB_PULL_REQUEST_PREVIEW),
86+
}),
8287
],
8388
optimization: {
8489
usedExports: true,

packages/console/src/console.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ function logMessage(
5555
message: string,
5656
...args: unknown[]
5757
) {
58-
if (process.env.NODE_ENV !== 'production' && !condition) {
58+
if (
59+
(process.env.GITHUB_PULL_REQUEST_PREVIEW ||
60+
process.env.NODE_ENV !== 'production') &&
61+
!condition
62+
) {
5963
if (typeof console[level] === 'function') {
6064
const renderStack = withRenderStack ? getRenderStack() : ''
6165
//@ts-expect-error level can be 'constructor' which is not callable

packages/ui-alerts/src/Alert/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ class Alert extends Component<AlertProps, AlertState> {
308308
}
309309

310310
render() {
311+
console.warn("[Heading]: Don't use 'as' with 'variant' ")
311312
const liveRegion = this.getLiveRegion()
312313
const screenReaderContent = liveRegion
313314
? this.createScreenReaderPortal(liveRegion)

0 commit comments

Comments
 (0)