mirror of
https://github.com/strapi/strapi.git
synced 2025-11-09 14:51:29 +00:00
Allow browser options while using watch-admin (#8054)
Signed-off-by: erictsangx <erictsangx@gmail.com>
This commit is contained in:
parent
b5ce86a805
commit
1e4c3b7237
@ -40,7 +40,7 @@ Strapi modifies/creates files at runtime and needs to restart when new files are
|
|||||||
|
|
||||||
```
|
```
|
||||||
strapi develop
|
strapi develop
|
||||||
options: [--no-build |--watch-admin ]
|
options: [--no-build |--watch-admin |--browser ]
|
||||||
```
|
```
|
||||||
|
|
||||||
- **strapi develop**<br/>
|
- **strapi develop**<br/>
|
||||||
@ -49,6 +49,8 @@ options: [--no-build |--watch-admin ]
|
|||||||
Starts your application with the autoReload enabled and skip the administration panel build process
|
Starts your application with the autoReload enabled and skip the administration panel build process
|
||||||
- **strapi develop --watch-admin**<br/>
|
- **strapi develop --watch-admin**<br/>
|
||||||
Starts your application with the autoReload enabled and the front-end development server. It allows you to customize the administration panel.
|
Starts your application with the autoReload enabled and the front-end development server. It allows you to customize the administration panel.
|
||||||
|
- **strapi develop --watch-admin --browser 'google chrome'**<br/>
|
||||||
|
Starts your application with the autoReload enabled and the front-end development server. It allows you to customize the administration panel. Provide a browser name to use instead of the default one, `false` means stop opening the browser.
|
||||||
|
|
||||||
::: tip
|
::: tip
|
||||||
You should never use this command to run a Strapi application in production.
|
You should never use this command to run a Strapi application in production.
|
||||||
|
|||||||
@ -233,7 +233,7 @@ async function createCacheDir(dir) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function watchAdmin({ dir, host, port, options }) {
|
async function watchAdmin({ dir, host, port, browser, options }) {
|
||||||
// Create the cache dir containing the front-end files.
|
// Create the cache dir containing the front-end files.
|
||||||
await createCacheDir(dir);
|
await createCacheDir(dir);
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ async function watchAdmin({ dir, host, port, options }) {
|
|||||||
clientLogLevel: 'silent',
|
clientLogLevel: 'silent',
|
||||||
hot: true,
|
hot: true,
|
||||||
quiet: true,
|
quiet: true,
|
||||||
open: true,
|
open: browser === 'true' ? true : browser,
|
||||||
publicPath: options.publicPath,
|
publicPath: options.publicPath,
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
index: options.publicPath,
|
index: options.publicPath,
|
||||||
|
|||||||
@ -127,6 +127,7 @@ program
|
|||||||
.alias('dev')
|
.alias('dev')
|
||||||
.option('--no-build', 'Disable build', false)
|
.option('--no-build', 'Disable build', false)
|
||||||
.option('--watch-admin', 'Enable watch', true)
|
.option('--watch-admin', 'Enable watch', true)
|
||||||
|
.option('--browser <name>', 'Open the browser', true)
|
||||||
.description('Start your Strapi application in development mode')
|
.description('Start your Strapi application in development mode')
|
||||||
.action(getLocalScript('develop'));
|
.action(getLocalScript('develop'));
|
||||||
|
|
||||||
@ -211,6 +212,7 @@ program
|
|||||||
// `$ strapi watch-admin`
|
// `$ strapi watch-admin`
|
||||||
program
|
program
|
||||||
.command('watch-admin')
|
.command('watch-admin')
|
||||||
|
.option('--browser <name>', 'Open the browser', true)
|
||||||
.description('Starts the admin dev server')
|
.description('Starts the admin dev server')
|
||||||
.action(getLocalScript('watchAdmin'));
|
.action(getLocalScript('watchAdmin'));
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const strapi = require('../index');
|
|||||||
* `$ strapi develop`
|
* `$ strapi develop`
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
module.exports = async function({ build, watchAdmin }) {
|
module.exports = async function({ build, watchAdmin, browser }) {
|
||||||
const dir = process.cwd();
|
const dir = process.cwd();
|
||||||
const config = loadConfiguration(dir);
|
const config = loadConfiguration(dir);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ module.exports = async function({ build, watchAdmin }) {
|
|||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
if (watchAdmin) {
|
if (watchAdmin) {
|
||||||
try {
|
try {
|
||||||
execa('npm', ['run', '-s', 'strapi', 'watch-admin'], {
|
execa('npm', ['run', '-s', 'strapi', 'watch-admin', '--', '--browser', browser], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const { getConfigUrls, getAbsoluteServerUrl } = require('strapi-utils');
|
|||||||
|
|
||||||
const addSlash = require('../utils/addSlash');
|
const addSlash = require('../utils/addSlash');
|
||||||
|
|
||||||
module.exports = async function() {
|
module.exports = async function({ browser }) {
|
||||||
const dir = process.cwd();
|
const dir = process.cwd();
|
||||||
|
|
||||||
const config = loadConfiguration(dir);
|
const config = loadConfiguration(dir);
|
||||||
@ -24,6 +24,7 @@ module.exports = async function() {
|
|||||||
dir,
|
dir,
|
||||||
port: adminPort,
|
port: adminPort,
|
||||||
host: adminHost,
|
host: adminHost,
|
||||||
|
browser,
|
||||||
options: {
|
options: {
|
||||||
backend: getAbsoluteServerUrl(config, true),
|
backend: getAbsoluteServerUrl(config, true),
|
||||||
publicPath: addSlash(adminPath),
|
publicPath: addSlash(adminPath),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user