Skip to content

Commit

Permalink
[Examples Browser] Build with local PCUI (#4976)
Browse files Browse the repository at this point in the history
* add support for a path to a local instance of pcui when building the examples browser
  • Loading branch information
ellthompson authored Jan 13, 2023
1 parent 0c790d0 commit 57d3445
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
50 changes: 50 additions & 0 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@playcanvas/eslint-config": "^1.1.1",
"@playcanvas/observer": "1.3.6",
"@playcanvas/pcui": "^3.3.1",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
Expand Down
27 changes: 26 additions & 1 deletion examples/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ import typescript from 'rollup-plugin-typescript2';
import copy from 'rollup-plugin-copy';
import { terser } from 'rollup-plugin-terser';
import { string } from 'rollup-plugin-string';
import alias from '@rollup/plugin-alias';
import path from 'path';

const PCUI_PATH = process.env.PCUI_PATH || 'node_modules/@playcanvas/pcui';
const PCUI_REACT_PATH = path.resolve(PCUI_PATH, 'react');
const PCUI_STYLES_PATH = path.resolve(PCUI_PATH, 'styles');

// define supported module overrides
const aliasEntries = {
'@playcanvas/pcui/react': PCUI_REACT_PATH,
'@playcanvas/pcui/styles': PCUI_STYLES_PATH
};

const tsCompilerOptions = {
baseUrl: '.',
paths: {
'@playcanvas/pcui/react': [PCUI_REACT_PATH],
'@playcanvas/pcui/styles': [PCUI_STYLES_PATH]
}
};

export default {
input: 'src/app/index.tsx',
Expand All @@ -24,9 +44,14 @@ export default {
{ src: '../scripts/*', dest: 'dist/static/scripts/' }
]
}),
alias({ entries: aliasEntries }),
commonjs(),
resolve(),
typescript(),
typescript({
tsconfig: 'tsconfig.json',
tsconfigDefaults: { compilerOptions: tsCompilerOptions },
clean: true
}),
replace({
values: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
Expand Down

0 comments on commit 57d3445

Please sign in to comment.