mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
refactor(v2): move core typing to types.ts (#1585)
* refactor(v2): move typing to types.ts * nits
This commit is contained in:
parent
bc761d41ad
commit
d98b4c50d2
21 changed files with 182 additions and 170 deletions
|
@ -6,10 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {DocusaurusConfig} from '../../server/config';
|
import {DocusaurusContext} from '../types';
|
||||||
|
|
||||||
export interface DocusaurusContext {
|
|
||||||
siteConfig?: DocusaurusConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default React.createContext<DocusaurusContext>({});
|
export default React.createContext<DocusaurusContext>({});
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {useContext} from 'react';
|
import {useContext} from 'react';
|
||||||
import DocusaurusContext from './context';
|
import context from './context';
|
||||||
|
import {DocusaurusContext} from '../types';
|
||||||
|
|
||||||
function useDocusaurusContext() {
|
function useDocusaurusContext(): DocusaurusContext {
|
||||||
return useContext(DocusaurusContext);
|
return useContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useDocusaurusContext;
|
export default useDocusaurusContext;
|
||||||
|
|
5
packages/docusaurus/src/client/types.ts
Normal file
5
packages/docusaurus/src/client/types.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import {DocusaurusConfig} from '../server/types';
|
||||||
|
|
||||||
|
export interface DocusaurusContext {
|
||||||
|
siteConfig?: DocusaurusConfig;
|
||||||
|
}
|
|
@ -5,20 +5,21 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import webpack, {Configuration, Plugin} from 'webpack';
|
import chalk from 'chalk';
|
||||||
import merge from 'webpack-merge';
|
|
||||||
import CleanWebpackPlugin from 'clean-webpack-plugin';
|
import CleanWebpackPlugin from 'clean-webpack-plugin';
|
||||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||||
import ReactLoadableSSRAddon from 'react-loadable-ssr-addon';
|
|
||||||
import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer';
|
|
||||||
import path from 'path';
|
|
||||||
import chalk from 'chalk';
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import {load, CLIOptions, Props} from '../server';
|
import path from 'path';
|
||||||
|
import ReactLoadableSSRAddon from 'react-loadable-ssr-addon';
|
||||||
|
import webpack, {Configuration, Plugin} from 'webpack';
|
||||||
|
import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer';
|
||||||
|
import merge from 'webpack-merge';
|
||||||
|
import {STATIC_DIR_NAME} from '../constants';
|
||||||
|
import {load} from '../server';
|
||||||
|
import {CLIOptions, Props} from '../server/types';
|
||||||
import {createClientConfig} from '../webpack/client';
|
import {createClientConfig} from '../webpack/client';
|
||||||
import {createServerConfig} from '../webpack/server';
|
import {createServerConfig} from '../webpack/server';
|
||||||
import {applyConfigureWebpack} from '../webpack/utils';
|
import {applyConfigureWebpack} from '../webpack/utils';
|
||||||
import {STATIC_DIR_NAME} from '../constants';
|
|
||||||
|
|
||||||
function compile(config: Configuration[]): Promise<any> {
|
function compile(config: Configuration[]): Promise<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import shell from 'shelljs';
|
import shell from 'shelljs';
|
||||||
import fs from 'fs-extra';
|
|
||||||
import {build} from './build';
|
|
||||||
import {loadConfig} from '../server/config';
|
|
||||||
import {CONFIG_FILE_NAME} from '../constants';
|
import {CONFIG_FILE_NAME} from '../constants';
|
||||||
|
import {loadConfig} from '../server/config';
|
||||||
|
import {build} from './build';
|
||||||
|
|
||||||
export async function deploy(siteDir: string): Promise<void> {
|
export async function deploy(siteDir: string): Promise<void> {
|
||||||
console.log('Deploy command invoked ...');
|
console.log('Deploy command invoked ...');
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import fs from 'fs-extra';
|
|
||||||
import shell from 'shelljs';
|
|
||||||
import inquirer from 'inquirer';
|
|
||||||
import path from 'path';
|
|
||||||
import _ from 'lodash';
|
|
||||||
import {execSync} from 'child_process';
|
import {execSync} from 'child_process';
|
||||||
|
import fs from 'fs-extra';
|
||||||
|
import inquirer from 'inquirer';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import path from 'path';
|
||||||
|
import shell from 'shelljs';
|
||||||
|
|
||||||
function hasYarn(): boolean {
|
function hasYarn(): boolean {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,22 +5,23 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import _ from 'lodash';
|
import {normalizeUrl} from '@docusaurus/utils';
|
||||||
import path from 'path';
|
|
||||||
import webpack from 'webpack';
|
|
||||||
import express from 'express';
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import chokidar from 'chokidar';
|
import chokidar from 'chokidar';
|
||||||
|
import express from 'express';
|
||||||
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import path from 'path';
|
||||||
import portfinder from 'portfinder';
|
import portfinder from 'portfinder';
|
||||||
import openBrowser from 'react-dev-utils/openBrowser';
|
import openBrowser from 'react-dev-utils/openBrowser';
|
||||||
import {prepareUrls} from 'react-dev-utils/WebpackDevServerUtils';
|
import {prepareUrls} from 'react-dev-utils/WebpackDevServerUtils';
|
||||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
import webpack from 'webpack';
|
||||||
import HotModuleReplacementPlugin from 'webpack/lib/HotModuleReplacementPlugin';
|
|
||||||
import WebpackDevServer from 'webpack-dev-server';
|
import WebpackDevServer from 'webpack-dev-server';
|
||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import {normalizeUrl} from '@docusaurus/utils';
|
import HotModuleReplacementPlugin from 'webpack/lib/HotModuleReplacementPlugin';
|
||||||
import {load, CLIOptions} from '../server';
|
|
||||||
import {CONFIG_FILE_NAME, STATIC_DIR_NAME} from '../constants';
|
import {CONFIG_FILE_NAME, STATIC_DIR_NAME} from '../constants';
|
||||||
|
import {load} from '../server';
|
||||||
|
import {CLIOptions} from '../server/types';
|
||||||
import {createClientConfig} from '../webpack/client';
|
import {createClientConfig} from '../webpack/client';
|
||||||
import {applyConfigureWebpack} from '../webpack/utils';
|
import {applyConfigureWebpack} from '../webpack/utils';
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import path from 'path';
|
import fs from 'fs-extra';
|
||||||
import importFresh from 'import-fresh';
|
import importFresh from 'import-fresh';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
export async function swizzle(
|
export async function swizzle(
|
||||||
siteDir: string,
|
siteDir: string,
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Plugin} from '../plugins';
|
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import {Plugin} from '../types';
|
||||||
|
|
||||||
export function loadClientModules(plugins: Plugin<any>[]): string[] {
|
export function loadClientModules(plugins: Plugin<any>[]): string[] {
|
||||||
return _.compact(
|
return _.compact(
|
||||||
|
|
|
@ -5,34 +5,12 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {PluginConfig} from './plugins';
|
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import _ from 'lodash';
|
|
||||||
import importFresh from 'import-fresh';
|
import importFresh from 'import-fresh';
|
||||||
|
import _ from 'lodash';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {CONFIG_FILE_NAME} from '../constants';
|
import {CONFIG_FILE_NAME} from '../constants';
|
||||||
import {PresetConfig} from './presets';
|
import {DocusaurusConfig, PluginConfig} from './types';
|
||||||
|
|
||||||
export interface DocusaurusConfig {
|
|
||||||
baseUrl: string;
|
|
||||||
favicon: string;
|
|
||||||
tagline: string;
|
|
||||||
title: string;
|
|
||||||
url: string;
|
|
||||||
organizationName?: string;
|
|
||||||
projectName?: string;
|
|
||||||
githubHost?: string;
|
|
||||||
plugins?: PluginConfig[];
|
|
||||||
themes?: PluginConfig[];
|
|
||||||
presets?: PresetConfig[];
|
|
||||||
themeConfig?: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
customFields?: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const REQUIRED_FIELDS = ['baseUrl', 'favicon', 'tagline', 'title', 'url'];
|
const REQUIRED_FIELDS = ['baseUrl', 'favicon', 'tagline', 'title', 'url'];
|
||||||
|
|
||||||
|
|
|
@ -5,38 +5,23 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {PluginConfig, Plugin} from './plugins';
|
|
||||||
|
|
||||||
import path from 'path';
|
|
||||||
import _ from 'lodash';
|
|
||||||
|
|
||||||
import {generate} from '@docusaurus/utils';
|
import {generate} from '@docusaurus/utils';
|
||||||
|
import _ from 'lodash';
|
||||||
import {loadConfig, DocusaurusConfig} from './config';
|
import path from 'path';
|
||||||
import {loadThemeAlias} from './themes';
|
import {CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME} from '../constants';
|
||||||
import {loadPlugins} from './plugins';
|
|
||||||
import {loadRoutes} from './routes';
|
|
||||||
import {loadPresets} from './presets';
|
|
||||||
import {loadClientModules} from './client-modules';
|
import {loadClientModules} from './client-modules';
|
||||||
|
import {loadConfig} from './config';
|
||||||
import {GENERATED_FILES_DIR_NAME, CONFIG_FILE_NAME} from '../constants';
|
import {loadPlugins} from './plugins';
|
||||||
|
import {loadPresets} from './presets';
|
||||||
export interface CLIOptions {
|
import {loadRoutes} from './routes';
|
||||||
[option: string]: any;
|
import {loadThemeAlias} from './themes';
|
||||||
}
|
import {
|
||||||
|
CLIOptions,
|
||||||
export interface LoadContext {
|
DocusaurusConfig,
|
||||||
siteDir: string;
|
LoadContext,
|
||||||
generatedFilesDir: string;
|
PluginConfig,
|
||||||
siteConfig: DocusaurusConfig;
|
Props,
|
||||||
cliOptions: CLIOptions;
|
} from './types';
|
||||||
outDir: string;
|
|
||||||
baseUrl: string;
|
|
||||||
}
|
|
||||||
export interface Props extends LoadContext {
|
|
||||||
routesPaths: string[];
|
|
||||||
plugins: Plugin<any>[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function load(
|
export async function load(
|
||||||
siteDir: string,
|
siteDir: string,
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {load, Props} from './index';
|
import {load} from './index';
|
||||||
|
import {Props} from './types';
|
||||||
|
|
||||||
// Helper methods to setup dummy/fake projects
|
// Helper methods to setup dummy/fake projects
|
||||||
export const loadSetup = async (name: string): Promise<Props> => {
|
export const loadSetup = async (name: string): Promise<Props> => {
|
||||||
|
|
|
@ -5,36 +5,17 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {LoadContext, Props} from '..';
|
import {generate} from '@docusaurus/utils';
|
||||||
import {RouteConfig} from '../routes';
|
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import importFresh from 'import-fresh';
|
import importFresh from 'import-fresh';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {generate} from '@docusaurus/utils';
|
import {
|
||||||
import {Configuration} from 'webpack';
|
LoadContext,
|
||||||
|
Plugin,
|
||||||
export interface Plugin<T> {
|
PluginConfig,
|
||||||
name: string;
|
PluginContentLoadedActions,
|
||||||
loadContent?(): T;
|
RouteConfig,
|
||||||
contentLoaded?({
|
} from '../types';
|
||||||
content: T,
|
|
||||||
actions: DocusaurusPluginContentLoadedActions,
|
|
||||||
}): void;
|
|
||||||
postBuild?(props: Props): void;
|
|
||||||
postStart?(props: Props): void;
|
|
||||||
configureWebpack?(config: Configuration, isServer: boolean): Configuration;
|
|
||||||
getThemePath?(): string;
|
|
||||||
getPathsToWatch?(): string[];
|
|
||||||
getClientModules?(): string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PluginConfig = [string, Object | undefined] | string;
|
|
||||||
|
|
||||||
export interface PluginContentLoadedActions {
|
|
||||||
addRoute(config: RouteConfig): void;
|
|
||||||
createData(name: string, data: Object): Promise<string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function loadPlugins({
|
export async function loadPlugins({
|
||||||
pluginConfigs,
|
pluginConfigs,
|
||||||
|
|
|
@ -5,18 +5,9 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {LoadContext} from '../index';
|
|
||||||
import {PluginConfig} from '../plugins';
|
|
||||||
|
|
||||||
import importFresh from 'import-fresh';
|
import importFresh from 'import-fresh';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import {LoadContext, PluginConfig, Preset, PresetConfig} from '../types';
|
||||||
export interface Preset {
|
|
||||||
plugins?: PluginConfig[];
|
|
||||||
themes?: PluginConfig[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PresetConfig = [string, Object | undefined] | string;
|
|
||||||
|
|
||||||
export function loadPresets(
|
export function loadPresets(
|
||||||
context: LoadContext,
|
context: LoadContext,
|
||||||
|
|
|
@ -6,33 +6,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {genChunkName} from '@docusaurus/utils';
|
import {genChunkName} from '@docusaurus/utils';
|
||||||
import {stringify, ParsedUrlQueryInput} from 'querystring';
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import {stringify} from 'querystring';
|
||||||
interface ChunkRegistry {
|
import {ChunkRegistry, Module, RouteConfig, RouteModule} from './types';
|
||||||
importStatement: string;
|
|
||||||
modulePath: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Module =
|
|
||||||
| {
|
|
||||||
path: string;
|
|
||||||
__import?: boolean;
|
|
||||||
query?: ParsedUrlQueryInput;
|
|
||||||
}
|
|
||||||
| string;
|
|
||||||
|
|
||||||
interface RouteModule {
|
|
||||||
[module: string]: Module | RouteModule | RouteModule[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RouteConfig {
|
|
||||||
path: string;
|
|
||||||
component: string;
|
|
||||||
modules?: RouteModule;
|
|
||||||
routes?: RouteConfig[];
|
|
||||||
exact?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getModulePath(target: Module): string {
|
function getModulePath(target: Module): string {
|
||||||
if (typeof target === 'string') {
|
if (typeof target === 'string') {
|
||||||
|
|
|
@ -9,10 +9,7 @@ import globby from 'globby';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {fileToPath, posixPath, normalizeUrl} from '@docusaurus/utils';
|
import {fileToPath, posixPath, normalizeUrl} from '@docusaurus/utils';
|
||||||
|
import {ThemeAlias} from '../types';
|
||||||
export interface ThemeAlias {
|
|
||||||
[alias: string]: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function themeAlias(themePath: string): ThemeAlias {
|
export function themeAlias(themePath: string): ThemeAlias {
|
||||||
if (!fs.pathExistsSync(themePath)) {
|
if (!fs.pathExistsSync(themePath)) {
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {themeAlias, ThemeAlias} from './alias';
|
import {ThemeAlias} from '../types';
|
||||||
|
import {themeAlias} from './alias';
|
||||||
export {ThemeAlias} from './alias';
|
|
||||||
|
|
||||||
export function loadThemeAlias(themePaths: string[]): ThemeAlias {
|
export function loadThemeAlias(themePaths: string[]): ThemeAlias {
|
||||||
return themePaths.reduce(
|
return themePaths.reduce(
|
||||||
|
|
100
packages/docusaurus/src/server/types.ts
Normal file
100
packages/docusaurus/src/server/types.ts
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
import {ParsedUrlQueryInput} from 'querystring';
|
||||||
|
import {Configuration} from 'webpack';
|
||||||
|
|
||||||
|
export interface DocusaurusConfig {
|
||||||
|
baseUrl: string;
|
||||||
|
favicon: string;
|
||||||
|
tagline: string;
|
||||||
|
title: string;
|
||||||
|
url: string;
|
||||||
|
organizationName?: string;
|
||||||
|
projectName?: string;
|
||||||
|
githubHost?: string;
|
||||||
|
plugins?: PluginConfig[];
|
||||||
|
themes?: PluginConfig[];
|
||||||
|
presets?: PresetConfig[];
|
||||||
|
themeConfig?: {
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
customFields?: {
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Preset {
|
||||||
|
plugins?: PluginConfig[];
|
||||||
|
themes?: PluginConfig[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PresetConfig = [string, Object | undefined] | string;
|
||||||
|
|
||||||
|
export interface CLIOptions {
|
||||||
|
[option: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoadContext {
|
||||||
|
siteDir: string;
|
||||||
|
generatedFilesDir: string;
|
||||||
|
siteConfig: DocusaurusConfig;
|
||||||
|
cliOptions: CLIOptions;
|
||||||
|
outDir: string;
|
||||||
|
baseUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Props extends LoadContext {
|
||||||
|
routesPaths: string[];
|
||||||
|
plugins: Plugin<any>[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PluginContentLoadedActions {
|
||||||
|
addRoute(config: RouteConfig): void;
|
||||||
|
createData(name: string, data: Object): Promise<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Plugin<T> {
|
||||||
|
name: string;
|
||||||
|
loadContent?(): T;
|
||||||
|
contentLoaded?({
|
||||||
|
content,
|
||||||
|
actions,
|
||||||
|
}: {
|
||||||
|
content: T;
|
||||||
|
actions: PluginContentLoadedActions;
|
||||||
|
}): void;
|
||||||
|
postBuild?(props: Props): void;
|
||||||
|
postStart?(props: Props): void;
|
||||||
|
configureWebpack?(config: Configuration, isServer: boolean): Configuration;
|
||||||
|
getThemePath?(): string;
|
||||||
|
getPathsToWatch?(): string[];
|
||||||
|
getClientModules?(): string[];
|
||||||
|
}
|
||||||
|
export type PluginConfig = [string, Object | undefined] | string;
|
||||||
|
|
||||||
|
export interface ChunkRegistry {
|
||||||
|
importStatement: string;
|
||||||
|
modulePath: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Module =
|
||||||
|
| {
|
||||||
|
path: string;
|
||||||
|
__import?: boolean;
|
||||||
|
query?: ParsedUrlQueryInput;
|
||||||
|
}
|
||||||
|
| string;
|
||||||
|
|
||||||
|
export interface RouteModule {
|
||||||
|
[module: string]: Module | RouteModule | RouteModule[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RouteConfig {
|
||||||
|
path: string;
|
||||||
|
component: string;
|
||||||
|
modules?: RouteModule;
|
||||||
|
routes?: RouteConfig[];
|
||||||
|
exact?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ThemeAlias {
|
||||||
|
[alias: string]: string;
|
||||||
|
}
|
|
@ -5,14 +5,15 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import fs from 'fs-extra';
|
||||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||||
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
|
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
|
||||||
import TerserPlugin from 'terser-webpack-plugin';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import TerserPlugin from 'terser-webpack-plugin';
|
||||||
import {Configuration} from 'webpack';
|
import {Configuration} from 'webpack';
|
||||||
|
|
||||||
|
import {Props} from '../server/types';
|
||||||
import {getBabelLoader, getCacheLoader, getStyleLoaders} from './utils';
|
import {getBabelLoader, getCacheLoader, getStyleLoaders} from './utils';
|
||||||
import {Props} from '../server';
|
|
||||||
|
|
||||||
const CSS_REGEX = /\.css$/;
|
const CSS_REGEX = /\.css$/;
|
||||||
const CSS_MODULE_REGEX = /\.module\.css$/;
|
const CSS_MODULE_REGEX = /\.module\.css$/;
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
*/
|
*/
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {Configuration} from 'webpack';
|
import {Configuration} from 'webpack';
|
||||||
import WebpackNiceLog from 'webpack-nicelog';
|
|
||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import ChunkManifestPlugin from './plugins/ChunkManifestPlugin';
|
import WebpackNiceLog from 'webpack-nicelog';
|
||||||
|
|
||||||
|
import {Props} from '../server/types';
|
||||||
import {createBaseConfig} from './base';
|
import {createBaseConfig} from './base';
|
||||||
import {Props} from '../server';
|
import ChunkManifestPlugin from './plugins/ChunkManifestPlugin';
|
||||||
|
|
||||||
export function createClientConfig(props: Props): Configuration {
|
export function createClientConfig(props: Props): Configuration {
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin';
|
import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin';
|
||||||
import WebpackNiceLog from 'webpack-nicelog';
|
|
||||||
import merge from 'webpack-merge';
|
|
||||||
import {Configuration} from 'webpack';
|
import {Configuration} from 'webpack';
|
||||||
|
import merge from 'webpack-merge';
|
||||||
|
import WebpackNiceLog from 'webpack-nicelog';
|
||||||
|
|
||||||
|
import {Props} from '../server/types';
|
||||||
import {createBaseConfig} from './base';
|
import {createBaseConfig} from './base';
|
||||||
import WaitPlugin from './plugins/WaitPlugin';
|
import WaitPlugin from './plugins/WaitPlugin';
|
||||||
import {Props} from '../server';
|
|
||||||
|
|
||||||
export function createServerConfig(props: Props): Configuration {
|
export function createServerConfig(props: Props): Configuration {
|
||||||
const {baseUrl, routesPaths, outDir} = props;
|
const {baseUrl, routesPaths, outDir} = props;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue