mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Use script to build the admin when developing
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
9a88eac51e
commit
1db862161b
@ -43,10 +43,10 @@ function getCustomWebpackConfig(dir, config) {
|
||||
return webpackConfig;
|
||||
}
|
||||
|
||||
async function build({ plugins, dir, env, options, optimize, useDefaultBuild }) {
|
||||
async function build({ plugins, dir, env, options, optimize, forceBuild }) {
|
||||
const buildAdmin = await shouldBuildAdmin({ dir, plugins });
|
||||
|
||||
if (!buildAdmin && useDefaultBuild) {
|
||||
if (!buildAdmin && !forceBuild) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +133,6 @@ program
|
||||
|
||||
program
|
||||
.command('build')
|
||||
.option('--use-default-build', 'Use the default build of the admin panel', false)
|
||||
.option('--clean', 'Remove the build and .cache folders', false)
|
||||
.option('--no-optimization', 'Build the Administration without assets optimization')
|
||||
.description('Builds the strapi admin app')
|
||||
|
||||
@ -12,7 +12,7 @@ const getEnabledPlugins = require('../core/loaders/plugins/get-enabled-plugins')
|
||||
/**
|
||||
* `$ strapi build`
|
||||
*/
|
||||
module.exports = async ({ clean, optimization, useDefaultBuild }) => {
|
||||
module.exports = async ({ clean, optimization, forceBuild = true }) => {
|
||||
const dir = process.cwd();
|
||||
|
||||
const strapiInstance = strapi({
|
||||
@ -36,7 +36,7 @@ module.exports = async ({ clean, optimization, useDefaultBuild }) => {
|
||||
|
||||
return strapiAdmin
|
||||
.build({
|
||||
useDefaultBuild,
|
||||
forceBuild,
|
||||
dir,
|
||||
plugins,
|
||||
// front end build env is always production for now
|
||||
@ -49,8 +49,6 @@ module.exports = async ({ clean, optimization, useDefaultBuild }) => {
|
||||
})
|
||||
.then(() => {
|
||||
console.log('Admin UI build successfully');
|
||||
|
||||
process.exit();
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
|
||||
@ -10,6 +10,7 @@ const { getOr } = require('lodash/fp');
|
||||
const { createLogger } = require('@strapi/logger');
|
||||
const loadConfiguration = require('../core/app-configuration');
|
||||
const strapi = require('../index');
|
||||
const buildAdmin = require('./build');
|
||||
|
||||
/**
|
||||
* `$ strapi develop`
|
||||
@ -28,10 +29,7 @@ module.exports = async function({ build, watchAdmin, polling, browser }) {
|
||||
// Don't run the build process if the admin is in watch mode
|
||||
if (build && !watchAdmin && serveAdminPanel && !buildExists) {
|
||||
try {
|
||||
execa.sync('npm run -s build -- --no-optimization --use-default-build', {
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
await buildAdmin({ clean: false, optimization: false, forceBuild: false });
|
||||
} catch (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user