Added --adminX functionality to yarn dev

fixes https://github.com/TryGhost/Toolbox/issues/581

- this adds support for spinning up AdminX within the `yarn dev` script
  with zero other steps needed
This commit is contained in:
Daniel Lockyer 2023-05-19 10:32:13 +02:00
parent 0c85012bdc
commit 58539c355b
No known key found for this signature in database
4 changed files with 17 additions and 17 deletions

11
.github/dev.js vendored
View File

@ -60,6 +60,17 @@ if (DASH_DASH_ARGS.includes('in-memory-repository') || DASH_DASH_ARGS.includes('
});
}
if (DASH_DASH_ARGS.includes('admin-x') || DASH_DASH_ARGS.includes('adminx') || DASH_DASH_ARGS.includes('adminX') || DASH_DASH_ARGS.includes('all')) {
commands.push({
name: 'adminX',
command: 'yarn dev',
cwd: path.resolve(__dirname, '../ghost/admin-x-settings'),
prefixColor: '#C35831',
env: {}
});
COMMAND_GHOST.env['adminX__url'] = 'http://localhost:4174/admin-x-settings.umd.js';
}
if (DASH_DASH_ARGS.includes('portal') || DASH_DASH_ARGS.includes('all')) {
commands.push({
name: 'portal',

View File

@ -15,22 +15,7 @@ Run `yarn dev` to start the development server to test/develop the settings stan
### Running inside Admin
To test/develop inside of Admin you can run `yarn preview` then in Ghost set your `adminX` value in `config.local.json` to `http://localhost:4173/admin-x-settings.umd.js` and load Admin as usual. Replace Ghost Admin's `settings` url with `settings-x` to load the new settings.
```json
{
...
"adminX": {
"url": "http://localhost:4173/admin-x-settings.umd.js"
}
}
```
`yarn preview` by itself only serves the library files, it's possible ro run `yarn build --watch` in a separate terminal tab to have auto-rebuild whilst developing.
## Usage
Run `yarn dev` from the top-level repo with `--adminX`
## Develop

View File

@ -26,7 +26,7 @@
"registry": "https://registry.npmjs.org/"
},
"scripts": {
"dev": "vite",
"dev": "concurrently \"vite preview\" \"vite build --watch\"",
"build": "tsc && vite build",
"lint": "yarn run lint:js",
"lint:js": "eslint --ext .js,.ts,.cjs,.tsx --cache src test",
@ -59,6 +59,7 @@
"@typescript-eslint/parser": "5.57.1",
"@vitejs/plugin-react": "4.0.0",
"autoprefixer": "10.4.14",
"concurrently": "8.0.1",
"eslint": "8.38.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-ghost": "2.18.0",

View File

@ -17,6 +17,9 @@ export default (function viteConfig() {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.VITEST_SEGFAULT_RETRY': 3
},
preview: {
port: 4174
},
build: {
minify: true,
sourcemap: true,