Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
- name: Build docs-app
run: npm run build:docs
if: github.event.action != 'closed'
env:
GITHUB_PULL_REQUEST_PREVIEW: 'true'
- uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./packages/__docs__/__build__
Expand Down
25 changes: 21 additions & 4 deletions packages/__docs__/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,26 @@ module.exports = {
presets: [
[
require('@instructure/ui-babel-preset'),
{
transformImports: false // needed for webpack reload on change to work,
}
{ transformImports: false } // use preset for dev builds
]
]
],
env: {
production: {
// In production, bypass the preset to preserve console logs
presets: [
[
'@babel/preset-env',
{
targets: '>0.25%, not dead',
modules: false
}
],
'@babel/preset-react',
'@babel/preset-typescript'
],
plugins: [
// Add any additional plugins you need, but do NOT include transform-remove-console
]
}
}
}
6 changes: 6 additions & 0 deletions packages/__docs__/webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ import { globbySync } from 'globby'
import { merge } from 'webpack-merge'
import { processSingleFile } from './lib/build-docs.mjs'
import resolve from './resolve.mjs'
import webpack from 'webpack'
import TerserPlugin from 'terser-webpack-plugin'

const ENV = process.env.NODE_ENV || 'production'
const DEBUG = process.env.DEBUG || ENV === 'development'
const GITHUB_PULL_REQUEST_PREVIEW = process.env.GITHUB_PULL_REQUEST_PREVIEW || 'false'

const outputPath = resolvePath(import.meta.dirname, '__build__')
const resolveAliases = DEBUG ? { resolve } : {}
Expand Down Expand Up @@ -79,6 +82,9 @@ const config = merge(baseConfig, {
template: './src/index.html',
chunks: ['main'],
}),
new webpack.DefinePlugin({
'process.env.GITHUB_PULL_REQUEST_PREVIEW': JSON.stringify(GITHUB_PULL_REQUEST_PREVIEW),
}),
],
optimization: {
usedExports: true,
Expand Down
6 changes: 5 additions & 1 deletion packages/console/src/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ function logMessage(
message: string,
...args: unknown[]
) {
if (process.env.NODE_ENV !== 'production' && !condition) {
if (
(process.env.GITHUB_PULL_REQUEST_PREVIEW ||
process.env.NODE_ENV !== 'production') &&
!condition
) {
if (typeof console[level] === 'function') {
const renderStack = withRenderStack ? getRenderStack() : ''
//@ts-expect-error level can be 'constructor' which is not callable
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-alerts/src/Alert/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ For more information about live regions, see
return (
<View key={alert.key} display="block" margin="small 0">
<Alert
screenReaderOnly
variant={alert.variant}
renderCloseButtonLabel="Close"
onDismiss={alert.onDismiss}
liveRegion={() => document.getElementById('flash-messages')}
//liveRegion={() => document.getElementById('flash-messages')}
liveRegionPoliteness={alert.politeness}
margin="small 0"
variantScreenReaderLabel={this.getScreenReaderLabel(
Expand Down
3 changes: 3 additions & 0 deletions packages/ui-alerts/src/Alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ class Alert extends Component<AlertProps, AlertState> {
}

render() {
// eslint-disable-next-line no-console
console.log('Hello from Alert')
console.warn('Warning from Alert')
const liveRegion = this.getLiveRegion()
const screenReaderContent = liveRegion
? this.createScreenReaderPortal(liveRegion)
Expand Down
Loading