mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 19:41:42 +08:00
feat(@vant/cli): support custom script extentions (#10624)
* feat(@vant/cli): support custom script extentions * fix: extensionsMap
This commit is contained in:
parent
0c0191332a
commit
173a364dae
@ -2,7 +2,7 @@ import fse from 'fs-extra';
|
||||
import babel from '@babel/core';
|
||||
import esbuild, { type Format } from 'esbuild';
|
||||
import { sep } from 'path';
|
||||
import { isJsx, replaceExt } from '../common/index.js';
|
||||
import { isJsx, replaceExt, getVantConfig } from '../common/index.js';
|
||||
import { replaceCSSImportExt } from '../common/css.js';
|
||||
import { replaceScriptImportExt } from './get-deps.js';
|
||||
|
||||
@ -50,7 +50,9 @@ export async function compileScript(
|
||||
|
||||
({ code } = esbuildResult);
|
||||
|
||||
const jsFilePath = replaceExt(filePath, '.js');
|
||||
const extensionMap = getVantConfig().build?.extensions;
|
||||
const extension = extensionMap?.[format] || '.js';
|
||||
const jsFilePath = replaceExt(filePath, extension);
|
||||
removeSync(filePath);
|
||||
outputFileSync(jsFilePath, code);
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ export function getViteConfigForPackage({
|
||||
}): InlineConfig {
|
||||
setBuildTarget('package');
|
||||
|
||||
const { name } = getVantConfig();
|
||||
const { name, build } = getVantConfig();
|
||||
const entryExtension = build?.extensions?.esm || '.js';
|
||||
const entry = join(ES_DIR, `index${entryExtension}`);
|
||||
|
||||
return {
|
||||
root: CWD,
|
||||
@ -24,7 +26,7 @@ export function getViteConfigForPackage({
|
||||
build: {
|
||||
lib: {
|
||||
name,
|
||||
entry: join(ES_DIR, 'index.js'),
|
||||
entry,
|
||||
formats,
|
||||
fileName: (format: string) => {
|
||||
const suffix = format === 'umd' ? '' : `.${format}`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user