mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-05 19:41:57 +08:00
fix: webpac5重构后重新支持https和proxy
This commit is contained in:
parent
cbbda6df42
commit
123e18f5a7
@ -1,3 +0,0 @@
|
|||||||
# fes
|
|
||||||
|
|
||||||
一个好用的前端应用解决方案
|
|
@ -2,7 +2,7 @@ import { join, resolve } from 'path';
|
|||||||
import { existsSync, readdirSync, readFileSync } from 'fs';
|
import { existsSync, readdirSync, readFileSync } from 'fs';
|
||||||
import { rimraf, chalk } from '@umijs/utils';
|
import { rimraf, chalk } from '@umijs/utils';
|
||||||
import zlib from 'zlib';
|
import zlib from 'zlib';
|
||||||
import getConfig from './webpackConfig/getConfig';
|
import getConfig from './webpackConfig';
|
||||||
|
|
||||||
export async function getBundleAndConfigs({
|
export async function getBundleAndConfigs({
|
||||||
api
|
api
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIETDCCArSgAwIBAgIQKxt9OXlPUkkQASISMtxezDANBgkqhkiG9w0BAQsFADBh
|
||||||
|
MR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQgQ0ExGzAZBgNVBAsMEmpjbEB5
|
||||||
|
Y2pjbDg2OC5sb2NhbDEiMCAGA1UEAwwZbWtjZXJ0IGpjbEB5Y2pjbDg2OC5sb2Nh
|
||||||
|
bDAeFw0xOTA2MDEwMDAwMDBaFw0zMDA2MDEwOTMzNTdaMEkxJzAlBgNVBAoTHm1r
|
||||||
|
Y2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTEeMBwGA1UECwwVamNsQHVtaWpz
|
||||||
|
LmxvY2FsICh1bWkpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvKA/
|
||||||
|
Oz9az6kEZ5zSZyufpYXt5gOAnE/f8VY2hP3g7JDRCMk6w0XgkmGDJ45nY9fVVhCy
|
||||||
|
oqg8bIkLcLbvp69/I5O8ae0TbyS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m+AOSjcSspPPfQmpHqupNaDJSjo6xYX3wn3oIb34WvH8INL3liiVedn+LTy4
|
||||||
|
-----END CERTIFICATE-----
|
@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8oD87P1rPqQRn
|
||||||
|
nNJnK5+lhe3mA4CcT9/xVjaE/eDskNEIyTrDReCSYYMnjmdj19VWELKiqDxsiQtw
|
||||||
|
tu+nr38jk7xp7RNvJL3maAF+WGCyqNKTJ2GfttmYB7k51m/4m0YGN3bZgOnOx4rT
|
||||||
|
PVWRfGAQApg6zGzNoKPpqS0CFNC8RHYNgajRdozrZI5A0viouf3tmuD6DwZKNL8K
|
||||||
|
D+9v6Tja0KCE6bQqzboIMGX3YPCXmah0SR/N7CuMLZY2V62Jm6mxfqmudEMFwZge
|
||||||
|
X5L/4P+IcJK7zciTGiiuwiKAaVJqH+dV962wocFNcVedLEvzpP0wDVHllxehW/Vx
|
||||||
|
Zk2KIwxrAgMBAAECggEAUdiitz2dVN/85kyYy2WVZ0g+2wCIDMtn25tSGtDiiSOp
|
||||||
|
YEuYsOSgNkQTmdVjrWIY0rh6GrQvS9UHXsgyIyu2WiSfq8LQHPjvYYudokoM41j3
|
||||||
|
zhxXcurvbdVkHOGcQl51uvrUGjqiuTPCXDiP6YnzUN8fWNwdFfhvR1M+EVog3J+F
|
||||||
|
RpSavm+SCOkyqCBWgQDb/p59kvlISJuDXKr3tV5HaKVKYfDBQLvuiZBweDwXjxop
|
||||||
|
z2Srs2GEmJPuKXU32deqNg7KgPvd6ADxb+GXhrGVBaj7dxi77E8nHL/aGutVE4ON
|
||||||
|
VqMwdWoRPkEPU33rF+CCxHqHJFcNS+62ozzeUYGlaQKBgQDR2mPnjthIgMkX+cw5
|
||||||
|
ROSadd5gZtQFXAzjAv685k+Xqm2IGk2Z2d5VydHO7cKwVLTB6cEJ+CbLZ1kIS6yV
|
||||||
|
GxBHaZ+LQxGkt4QD9IBSnL9Cxe7uvo+bpvV3eXbANG0tNl482RctS/u+g+OGSu05
|
||||||
|
6KIIlYag5hcMjr7ozuhv8LVytwKBgQDmGuIKFHXXqeRJNW+QvJfwQFKNQViqASlY
|
||||||
|
W4Y5guS6s85inJ3bRKwYtZsczne2uwYqQHlPw8X4TQMXApM+04mJtqwrYDpcX6Ad
|
||||||
|
VYPmo+J/k917QwlN8VP4AzlDdz8PU+zenmWgpKaG8GMtYia9qCIbWY/+hwwBk0sG
|
||||||
|
FNpguWnv7QKBgFSGT2ksSwdhAB5tGgoTKrTgNvLDWDDUc8hYI3y4k2R2W+nPFmSa
|
||||||
|
sYgCY0Si1aEqbSgR3BQE5LNW7DCAMoJYRUVOUNnJ6Ohclor1R15/DjZ5/RQioztB
|
||||||
|
k2tM/DzMoRDt7iU6F7DCAyMoglNMCKMjhWhJudFC/BOtx02EUXENFjifAoGAD966
|
||||||
|
yEcw+XbWL9Zno2vebsuA5g0juFXsLBPj5gOJEvdjvJlgqcbKt8mOsSXsS8YKXs+j
|
||||||
|
jkTKWp21INkknqioS781kKhKXiSaPmuvdTDIZlQkamPtOFr0l55hTK3kw4HeTFxQ
|
||||||
|
VgwFEDl0HaUvVtVJxOkgbUWTJmiqO/kkNpeTHuECgYEAtD4dRK3w65d9BWHqgeOV
|
||||||
|
IVSDeYjA6gNuC3tuGzk9bA70U0X/T8+EQMuKNvRZC61/JzAlzEH1oGIw8md8Ki86
|
||||||
|
aRT96Gce7Q0FA3SaQ+h+w+kgsJG/aly3IThaJh/mx6HN7Xry6BFO1vlYlgdlm/1G
|
||||||
|
iKX/ppCt7bJYqfrptWs42u4=
|
||||||
|
-----END PRIVATE KEY-----
|
@ -1,11 +1,15 @@
|
|||||||
import WebpackDevServer from 'webpack-dev-server';
|
import WebpackDevServer from 'webpack-dev-server';
|
||||||
import webpack from 'webpack';
|
import webpack from 'webpack';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
|
||||||
export function startDevServer({
|
export function startDevServer({
|
||||||
webpackConfig,
|
webpackConfig,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
|
proxy,
|
||||||
|
https,
|
||||||
beforeMiddlewares,
|
beforeMiddlewares,
|
||||||
afterMiddlewares,
|
afterMiddlewares,
|
||||||
customerDevServerConfig
|
customerDevServerConfig
|
||||||
@ -18,6 +22,7 @@ export function startDevServer({
|
|||||||
noInfo: true,
|
noInfo: true,
|
||||||
clientLogLevel: 'silent',
|
clientLogLevel: 'silent',
|
||||||
stats: 'errors-only',
|
stats: 'errors-only',
|
||||||
|
proxy,
|
||||||
before: (app) => {
|
before: (app) => {
|
||||||
beforeMiddlewares.forEach((middleware) => {
|
beforeMiddlewares.forEach((middleware) => {
|
||||||
app.use(middleware);
|
app.use(middleware);
|
||||||
@ -33,6 +38,11 @@ export function startDevServer({
|
|||||||
},
|
},
|
||||||
...(customerDevServerConfig || {})
|
...(customerDevServerConfig || {})
|
||||||
};
|
};
|
||||||
|
if (https) {
|
||||||
|
options.https = true;
|
||||||
|
options.key = fs.readFileSync(path.resolve(__dirname, './cert/key.pem'));
|
||||||
|
options.cert = fs.readFileSync(path.resolve(__dirname, './cert/cert.pem'));
|
||||||
|
}
|
||||||
WebpackDevServer.addDevServerEntrypoints(webpackConfig, options);
|
WebpackDevServer.addDevServerEntrypoints(webpackConfig, options);
|
||||||
const compiler = webpack(webpackConfig);
|
const compiler = webpack(webpackConfig);
|
||||||
const server = new WebpackDevServer(compiler, options);
|
const server = new WebpackDevServer(compiler, options);
|
||||||
|
@ -42,13 +42,18 @@ export default (api) => {
|
|||||||
port = await portfinder.getPortPromise({
|
port = await portfinder.getPortPromise({
|
||||||
port: defaultPort ? parseInt(String(defaultPort), 10) : 8000
|
port: defaultPort ? parseInt(String(defaultPort), 10) : 8000
|
||||||
});
|
});
|
||||||
hostname = process.env.HOST || api.config.devServer?.host || '0.0.0.0';
|
hostname = process.env.HOST || api.config.devServer?.host || 'localhost';
|
||||||
console.log(chalk.cyan(`Starting the development server http://${hostname}:${port} ...`));
|
|
||||||
process.send({
|
process.send({
|
||||||
type: 'UPDATE_PORT',
|
type: 'UPDATE_PORT',
|
||||||
port
|
port
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// enable https
|
||||||
|
const isHTTPS = process.env.HTTPS || args.https;
|
||||||
|
|
||||||
|
console.log(chalk.cyan(`Starting the development server ${isHTTPS ? 'https' : 'http'}://${hostname}:${port} ...`));
|
||||||
|
|
||||||
cleanTmpPathExceptCache({
|
cleanTmpPathExceptCache({
|
||||||
absTmpPath: paths.absTmpPath
|
absTmpPath: paths.absTmpPath
|
||||||
});
|
});
|
||||||
@ -163,6 +168,7 @@ export default (api) => {
|
|||||||
host: hostname,
|
host: hostname,
|
||||||
port,
|
port,
|
||||||
proxy: api.config.proxy,
|
proxy: api.config.proxy,
|
||||||
|
https: isHTTPS,
|
||||||
beforeMiddlewares,
|
beforeMiddlewares,
|
||||||
afterMiddlewares: [...middlewares],
|
afterMiddlewares: [...middlewares],
|
||||||
customerDevServerConfig: api.config.devServer
|
customerDevServerConfig: api.config.devServer
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"build": "fes build",
|
"build": "fes build",
|
||||||
"prod": "FES_ENV=prod fes build",
|
"prod": "FES_ENV=prod fes build",
|
||||||
"analyze": "ANALYZE=1 fes build",
|
"analyze": "ANALYZE=1 fes build",
|
||||||
"dev": "fes dev",
|
"dev": "fes dev --https",
|
||||||
"test:unit": "fes test:unit"
|
"test:unit": "fes test:unit"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user