mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types(cli): fix WebpackConfig type
This commit is contained in:
parent
4aff784d65
commit
c0308e9b96
@ -36,8 +36,6 @@
|
||||
"@types/fs-extra": "^9.0.1",
|
||||
"@types/lodash": "^4.14.153",
|
||||
"@types/postcss-load-config": "^2.0.1",
|
||||
"@types/webpack": "^4.41.13",
|
||||
"@types/webpack-dev-server": "^3.11.0",
|
||||
"@types/webpack-merge": "^4.1.5"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -49,6 +47,8 @@
|
||||
"@babel/preset-typescript": "^7.10.1",
|
||||
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
|
||||
"@types/jest": "^25.2.3",
|
||||
"@types/webpack": "^4.41.13",
|
||||
"@types/webpack-dev-server": "^3.11.0",
|
||||
"@vant/eslint-config": "^2.2.2",
|
||||
"@vant/markdown-loader": "^2.3.0",
|
||||
"@vant/markdown-vetur": "^2.0.1",
|
||||
|
6
packages/vant-cli/src/common/types.ts
Normal file
6
packages/vant-cli/src/common/types.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import type Webpack from 'webpack';
|
||||
import type WebpackDevServer from 'webpack-dev-server';
|
||||
|
||||
export type WebpackConfig = Webpack.Configuration & {
|
||||
devServer?: WebpackDevServer.Configuration;
|
||||
};
|
@ -4,6 +4,7 @@ import { VueLoaderPlugin } from 'vue-loader';
|
||||
import { join } from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
import { consola } from '../common/logger';
|
||||
import { WebpackConfig } from '../common/types';
|
||||
import {
|
||||
CWD,
|
||||
CACHE_DIR,
|
||||
@ -61,7 +62,7 @@ if (existsSync(tsconfigPath)) {
|
||||
);
|
||||
}
|
||||
|
||||
export const baseConfig = {
|
||||
export const baseConfig: WebpackConfig = {
|
||||
mode: 'development',
|
||||
resolve: {
|
||||
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS],
|
||||
|
@ -1,10 +1,11 @@
|
||||
import merge from 'webpack-merge';
|
||||
import { join } from 'path';
|
||||
import { baseConfig } from './webpack.base';
|
||||
import { WebpackConfig } from '../common/types';
|
||||
import { getVantConfig, getWebpackConfig, setBuildTarget } from '../common';
|
||||
import { LIB_DIR, ES_DIR } from '../common/constant';
|
||||
|
||||
export function getPackageConfig(isMinify: boolean) {
|
||||
export function getPackageConfig(isMinify: boolean): WebpackConfig {
|
||||
const { name } = getVantConfig();
|
||||
|
||||
setBuildTarget('package');
|
||||
|
@ -4,6 +4,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import { get } from 'lodash';
|
||||
import { join } from 'path';
|
||||
import { baseConfig } from './webpack.base';
|
||||
import { WebpackConfig } from '../common/types';
|
||||
import { getVantConfig, getWebpackConfig } from '../common';
|
||||
import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin';
|
||||
import {
|
||||
@ -12,7 +13,7 @@ import {
|
||||
SITE_DESKTOP_SHARED_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
export function getSiteDevBaseConfig() {
|
||||
export function getSiteDevBaseConfig(): WebpackConfig {
|
||||
const vantConfig = getVantConfig();
|
||||
const baiduAnalytics = get(vantConfig, 'site.baiduAnalytics');
|
||||
|
||||
@ -101,6 +102,6 @@ export function getSiteDevBaseConfig() {
|
||||
});
|
||||
}
|
||||
|
||||
export function getSiteDevConfig() {
|
||||
export function getSiteDevConfig(): WebpackConfig {
|
||||
return merge(getSiteDevBaseConfig(), getWebpackConfig());
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import merge from 'webpack-merge';
|
||||
import { get } from 'lodash';
|
||||
import { WebpackConfig } from '../common/types';
|
||||
import { getVantConfig, getWebpackConfig } from '../common';
|
||||
import { getSiteDevBaseConfig } from './webpack.site.dev';
|
||||
import { SITE_DIST_DIR } from '../common/constant';
|
||||
@ -8,7 +9,7 @@ const vantConfig = getVantConfig();
|
||||
const outputDir = get(vantConfig, 'build.site.outputDir', SITE_DIST_DIR);
|
||||
const publicPath = get(vantConfig, 'build.site.publicPath', '/');
|
||||
|
||||
export function getSitePrdConfig() {
|
||||
export function getSitePrdConfig(): WebpackConfig {
|
||||
return merge(
|
||||
getSiteDevBaseConfig(),
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user