mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 19:04:38 +00:00
Merge pull request #10554 from strapi/core/prebuild-admin
Prebuild admin panel
This commit is contained in:
commit
f3c76c29d8
@ -2,7 +2,7 @@ import React, { memo } from 'react';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import favicon from '../../favicon.png';
|
||||
import favicon from '../../favicon.ico';
|
||||
|
||||
const PageTitle = ({ title }) => {
|
||||
return <Helmet title={title} link={[{ rel: 'icon', type: 'image/png', href: favicon }]} />;
|
||||
|
||||
BIN
packages/core/admin/admin/src/favicon.ico
Normal file
BIN
packages/core/admin/admin/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 859 B |
@ -7,6 +7,7 @@
|
||||
"url": "git://github.com/strapi/strapi.git"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "node ./scripts/build.js",
|
||||
"test": "echo \"no tests yet\"",
|
||||
"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",
|
||||
|
||||
67
packages/core/admin/scripts/build.js
Normal file
67
packages/core/admin/scripts/build.js
Normal 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);
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user