Skip to content

Commit

Permalink
fix: cover js
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbao1001 committed Aug 22, 2024
1 parent ba8e33c commit 4b93f51
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/builder/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ export function normalizeUserConfig(
jsMinifier: JSMinifier.terser,
output: {
filename: entryOutput.filename
? `${entryOutput.filename}${
singleConfig.generateUnminified ? '.min' : ''
}`
? entryOutput.filename.replace(
/(\.js)?$/,
singleConfig.generateUnminified ? '.min.js' : '.js',
)
: `${path.parse(entry).name}.min.js`,
path: entryOutput.path || output.path || 'dist/umd',
},
Expand All @@ -175,20 +176,18 @@ export function normalizeUserConfig(
const defaultEntry = entryConfig || 'src/index';
const defaultFileName = getAutoBundleFilename(pkg.name);
if (umd.generateUnminified) {
if (umd.generateUnminified) {
assert(
!output.filename?.includes('.min'),
'if set generateUnminified enabled, you need to delete ".min" in the output filename config',
);
}
assert(
!output.filename?.includes('.min'),
'if set generateUnminified enabled, you need to delete ".min" in the output filename config',
);
configs.push({
...bundleConfig,
entry: defaultEntry,
jsMinifier: JSMinifier.none,
sourcemap: false,
output: {
filename: output.filename
? `${output.filename}.js`
? `${output.filename}`
: `${defaultFileName}.js`,
path: output.path || 'dist/umd',
},
Expand All @@ -201,7 +200,10 @@ export function normalizeUserConfig(
jsMinifier: JSMinifier.terser,
output: {
filename: output.filename
? `${output.filename}${umd.generateUnminified ? '.min' : ''}`
? output.filename.replace(
/(\.js)?$/,
umd.generateUnminified ? '.min.js' : '.js',
)
: `${defaultFileName}.min.js`,
path: output.path || 'dist/umd',
},
Expand Down

0 comments on commit 4b93f51

Please sign in to comment.