Merge pull request #10554 from strapi/core/prebuild-admin

Prebuild admin panel
This commit is contained in:
cyril lopez 2021-06-28 10:41:22 +02:00 committed by GitHub
commit f3c76c29d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 1 deletions

View File

@ -2,7 +2,7 @@ import React, { memo } from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import favicon from '../../favicon.png'; import favicon from '../../favicon.ico';
const PageTitle = ({ title }) => { const PageTitle = ({ title }) => {
return <Helmet title={title} link={[{ rel: 'icon', type: 'image/png', href: favicon }]} />; return <Helmet title={title} link={[{ rel: 'icon', type: 'image/png', href: favicon }]} />;

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 B

View File

@ -7,6 +7,7 @@
"url": "git://github.com/strapi/strapi.git" "url": "git://github.com/strapi/strapi.git"
}, },
"scripts": { "scripts": {
"prepublishOnly": "node ./scripts/build.js",
"test": "echo \"no tests yet\"", "test": "echo \"no tests yet\"",
"develop": "webpack serve --config webpack.config.dev.js --progress profile", "develop": "webpack serve --config webpack.config.dev.js --progress profile",
"develop:ce": "STRAPI_DISABLE_EE=true webpack serve --config webpack.config.dev.js --progress profile", "develop:ce": "STRAPI_DISABLE_EE=true webpack serve --config webpack.config.dev.js --progress profile",

View File

@ -0,0 +1,67 @@
'use strict';
const path = require('path');
const webpack = require('webpack');
const webpackConfig = require('../webpack.config');
const buildAdmin = async () => {
const entry = path.join(__dirname, '..', 'admin', 'src');
const dest = path.join(__dirname, '..', 'build');
const args = {
entry,
dest,
env: 'production',
optimize: true,
options: {
backend: 'http://localhost:1337',
adminPath: '/admin/',
features: [],
},
useEE: false,
};
const compiler = webpack(webpackConfig(args));
console.log('Building the admin panel');
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
let messages;
if (err) {
if (!err.message) {
return reject(err);
}
messages = {
errors: [err.message],
warnings: [],
};
} else {
messages = stats.toJson({ all: false, warnings: true, errors: true });
}
if (messages.errors.length) {
// Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise.
if (messages.errors.length > 1) {
messages.errors.length = 1;
}
return reject(new Error(messages.errors.join('\n\n')));
}
return resolve({
stats,
warnings: messages.warnings,
});
});
});
};
buildAdmin()
.then(() => {
process.exit();
})
.catch(err => {
console.error(err);
process.exit(1);
});