feat(admin): init project (#7197)

This commit is contained in:
Brooooooklyn
2024-06-18 06:01:13 +00:00
parent d216606193
commit 0fe672efa5
92 changed files with 6392 additions and 175 deletions

View File

@@ -1,14 +1,10 @@
import path from 'node:path';
import webpack from 'webpack';
import { getCwdFromDistribution } from '../config/cwd.cjs';
import type { BuildFlags } from '../config/index.js';
import { projectRoot } from '../config/index.js';
import { buildI18N } from '../util/i18n.js';
import { createWebpackConfig } from '../webpack/webpack.config.js';
let cwd: string;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const buildType = process.env.BUILD_TYPE_OVERRIDE || process.env.BUILD_TYPE;
@@ -37,24 +33,14 @@ let entry: string | undefined;
const { DISTRIBUTION } = process.env;
const getDistribution = () => {
switch (DISTRIBUTION) {
case 'browser':
case undefined:
cwd = path.join(projectRoot, 'packages/frontend/web');
return 'browser';
case 'desktop':
cwd = path.join(projectRoot, 'packages/frontend/electron/renderer');
entry = path.join(cwd, 'index.tsx');
return DISTRIBUTION;
default: {
throw new Error('DISTRIBUTION must be one of browser, desktop');
}
}
};
const cwd = getCwdFromDistribution(DISTRIBUTION);
if (DISTRIBUTION === 'desktop') {
entry = './index.tsx';
}
const flags = {
distribution: getDistribution(),
distribution: DISTRIBUTION as BuildFlags['distribution'],
mode: 'production',
channel: getChannel(),
coverage: process.env.COVERAGE === 'true',

View File

@@ -6,8 +6,8 @@ import { config } from 'dotenv';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import { getCwdFromDistribution, projectRoot } from '../config/cwd.cjs';
import type { BuildFlags } from '../config/index.js';
import { projectRoot } from '../config/index.js';
import { watchI18N } from '../util/i18n.js';
import { createWebpackConfig } from '../webpack/webpack.config.js';
@@ -46,6 +46,9 @@ const buildFlags = process.argv.includes('--static')
{
value: 'desktop',
},
{
value: 'admin',
},
],
initialValue: 'browser',
}),
@@ -103,13 +106,12 @@ flags.channel = buildFlags.channel;
flags.coverage = buildFlags.coverage;
flags.entry = undefined;
const cwd =
flags.distribution === 'browser'
? join(projectRoot, 'packages', 'frontend', 'web')
: join(projectRoot, 'packages', 'frontend', 'electron');
const cwd = getCwdFromDistribution(flags.distribution);
process.env.DISTRIBUTION = flags.distribution;
if (flags.distribution === 'desktop') {
flags.entry = join(cwd, 'renderer', 'index.tsx');
flags.entry = join(cwd, 'index.tsx');
}
if (buildFlags.debugBlockSuite) {