mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-10-07 17:29:58 +08:00
parent
04f67f16bc
commit
4424b77cbc
@ -91,6 +91,10 @@ export function decamelize(str: string, sep = '-') {
|
|||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function normalizePath(path: string): string {
|
||||||
|
return path.replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
|
||||||
export function getWebpackConfig(): object {
|
export function getWebpackConfig(): object {
|
||||||
if (existsSync(WEBPACK_CONFIG_FILE)) {
|
if (existsSync(WEBPACK_CONFIG_FILE)) {
|
||||||
const config = require(WEBPACK_CONFIG_FILE);
|
const config = require(WEBPACK_CONFIG_FILE);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { pascalize, getComponents, smartOutputFile } from '../common';
|
import { pascalize, getComponents, smartOutputFile, normalizePath } from '../common';
|
||||||
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
@ -16,7 +16,7 @@ function genImports(components: string[], options: Options): string {
|
|||||||
path = options.pathResolver(path);
|
path = options.pathResolver(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return `import ${pascalize(name)} from '${path}';`;
|
return `import ${pascalize(name)} from '${normalizePath(path)}';`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { existsSync } from 'fs-extra';
|
import { existsSync } from 'fs-extra';
|
||||||
import { smartOutputFile } from '../common';
|
import { smartOutputFile, normalizePath } from '../common';
|
||||||
import { CSS_LANG, getCssBaseFile } from '../common/css';
|
import { CSS_LANG, getCssBaseFile } from '../common/css';
|
||||||
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
|
import { SRC_DIR, STYPE_DEPS_JSON_FILE } from '../common/constant';
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ export function genPacakgeStyle(options: Options) {
|
|||||||
baseFile = options.pathResolver(baseFile);
|
baseFile = options.pathResolver(baseFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
content += `@import "${baseFile}";\n`;
|
content += `@import "${normalizePath(baseFile)}";\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
content += styleDepsJson.sequence
|
content += styleDepsJson.sequence
|
||||||
@ -36,7 +36,7 @@ export function genPacakgeStyle(options: Options) {
|
|||||||
path = options.pathResolver(path);
|
path = options.pathResolver(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return `@import "${path}";`;
|
return `@import "${normalizePath(path)}";`;
|
||||||
})
|
})
|
||||||
.filter((item: string) => !!item)
|
.filter((item: string) => !!item)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
pascalize,
|
pascalize,
|
||||||
removeExt,
|
removeExt,
|
||||||
getVantConfig,
|
getVantConfig,
|
||||||
smartOutputFile
|
smartOutputFile,
|
||||||
|
normalizePath
|
||||||
} from '../common';
|
} from '../common';
|
||||||
import {
|
import {
|
||||||
SRC_DIR,
|
SRC_DIR,
|
||||||
@ -65,19 +66,19 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const staticDocs = glob.sync(join(DOCS_DIR, '**/*.md')).map(path => {
|
const staticDocs = glob.sync(join(DOCS_DIR, '**/*.md')).map(path => {
|
||||||
const pairs = parse(path).name.split('.');
|
const pairs = parse(path.toString()).name.split('.');
|
||||||
return {
|
return {
|
||||||
name: formatName(pairs[0], pairs[1] || defaultLang),
|
name: formatName(pairs[0], pairs[1] || defaultLang),
|
||||||
path
|
path
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return [...staticDocs, ...docs.filter(item => existsSync(item.path))];
|
return [...staticDocs, ...docs.filter(item => existsSync(item.path))] as DocumentItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function genImportDocuments(items: DocumentItem[]) {
|
function genImportDocuments(items: DocumentItem[]) {
|
||||||
return items
|
return items
|
||||||
.map(item => `import ${item.name} from '${item.path}';`)
|
.map(item => `import ${item.name} from '${normalizePath(item.path)}';`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ function genExportDocuments(items: DocumentItem[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function genImportConfig() {
|
function genImportConfig() {
|
||||||
return `import config from '${removeExt(VANT_CONFIG_FILE)}';`;
|
return `import config from '${removeExt(normalizePath(VANT_CONFIG_FILE))}';`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function genExportConfig() {
|
function genExportConfig() {
|
||||||
|
@ -6,7 +6,8 @@ import {
|
|||||||
removeExt,
|
removeExt,
|
||||||
decamelize,
|
decamelize,
|
||||||
getVantConfig,
|
getVantConfig,
|
||||||
smartOutputFile
|
smartOutputFile,
|
||||||
|
normalizePath
|
||||||
} from '../common';
|
} from '../common';
|
||||||
|
|
||||||
type DemoItem = {
|
type DemoItem = {
|
||||||
@ -24,7 +25,7 @@ import './package-style';
|
|||||||
|
|
||||||
function genImports(demos: DemoItem[]) {
|
function genImports(demos: DemoItem[]) {
|
||||||
return demos
|
return demos
|
||||||
.map(item => `import ${item.name} from '${removeExt(item.path)}';`)
|
.map(item => `import ${item.name} from '${removeExt(normalizePath(item.path))}';`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user