How to use strapi-admin - 4 common examples

To help you get started, we’ve selected a few strapi-admin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strapi / strapi / packages / strapi / lib / commands / build.js View on Github external
env
      )}.\nMake sure the directory ${yellow(
        `./config/environments/${env}`
      )} exists`
    );
    process.exit(1);
  }

  const serverConfig = await loadConfigFile(envConfigDir, 'server.+(js|json)');

  const adminPath = _.get(serverConfig, 'admin.path', '/admin');
  const adminBackend = _.get(serverConfig, 'admin.build.backend', '/');

  console.log(`Building your admin UI with ${green(env)} configuration ...`);

  return strapiAdmin
    .build({
      dir,
      // front end build env is always production for now
      env: 'production',
      optimize: optimization,
      options: {
        backend: adminBackend,
        publicPath: addSlash(adminPath),
      },
    })
    .then(() => {
      process.exit();
    })
    .catch(err => {
      console.error(err);
      process.exit(1);
github strapi / strapi / packages / strapi / lib / commands / watch.js View on Github external
// The plugins.js file needs to be recreated
            // when we delete either the admin folder
            // the admin/src folder
            // or the plugins.js file
            // since the path are different when developing inside the monorepository or inside an app
            const shouldCopyPluginsJSFile =
              filePath.split('/admin/src').filter(p => !!p).length === 1;

            if (
              (event === 'unlinkDir' &&
                !isExtension &&
                shouldCopyPluginsJSFile) ||
              (!isExtension && filePath.includes('plugins.js'))
            ) {
              await strapiAdmin.createPluginsJs(
                appPlugins,
                path.join(cacheDir)
              );
            }
          } catch (err) {
            // Do nothing
          }
        }
      } else {
        // In any other case just copy the file into the .cache folder
        try {
          await fs.copy(filePath, path.join(destFolder, targetPath));
        } catch (err) {
          console.log(err);
        }
      }
github strapi / strapi / packages / strapi / lib / commands / watch.js View on Github external
const envConfigDir = path.join(dir, 'config', 'environments', 'development');
  const serverConfig = await loadConfigFile(envConfigDir, 'server.+(js|json)');

  const port = _.get(serverConfig, 'port', 1337);
  const host = _.get(serverConfig, 'host', 'localhost');
  const adminPort = _.get(serverConfig, 'admin.port', 8000);
  const adminBackend = _.get(
    serverConfig,
    'admin.build.backend',
    `http://${host}:${port}`
  );
  const adminPath = _.get(serverConfig, 'admin.path', '/admin');

  watchFiles();
  strapiAdmin.watch({
    dir,
    port: adminPort,
    options: {
      backend: adminBackend,
      publicPath: addSlash(adminPath),
    },
  });
};
github strapi / strapi / packages / strapi / lib / commands / watchAdmin.js View on Github external
const dir = process.cwd();
  const envConfigDir = path.join(dir, 'config', 'environments', 'development');
  const serverConfig = await loadConfigFile(envConfigDir, 'server.+(js|json)');

  const port = _.get(serverConfig, 'port', 1337);
  const host = _.get(serverConfig, 'host', 'localhost');
  const adminPort = _.get(serverConfig, 'admin.port', 8000);
  const adminHost = _.get(serverConfig, 'admin.host', 'localhost');
  const adminBackend = _.get(
    serverConfig,
    'admin.build.backend',
    `http://${host}:${port}`
  );
  const adminPath = _.get(serverConfig, 'admin.path', '/admin');

  strapiAdmin.watchAdmin({
    dir,
    port: adminPort,
    host: adminHost,
    options: {
      backend: adminBackend,
      publicPath: addSlash(adminPath),
    },
  });
};

strapi-admin

Strapi Admin

SEE LICENSE IN LICENSE
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis

Similar packages