Skip to content

Commit

Permalink
Merge pull request #18 from luo3house/fix-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
3lang3 committed May 9, 2023
2 parents 4225953 + 2413bf5 commit d588656
Show file tree
Hide file tree
Showing 2 changed files with 2,933 additions and 2,744 deletions.
11 changes: 10 additions & 1 deletion packages/cli/src/config/vite.package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@ export function getViteConfigForPackage({
entry,
formats: [format],
fileName: (fmt: string) => {
const isModulePkg = pkgJSON.type === 'module';
const isESMFile = /esm?/.test(fmt);
const ext = (function () {
if ((isModulePkg && isESMFile) || (!isModulePkg && !isESMFile)) {
return 'js';
} else {
return isESMFile ? 'mjs' : 'cjs';
}
})();
const suffix = fmt === 'umd' ? '' : `.${fmt}`;
return minify ? `${name}${suffix}.min.js` : `${name}${suffix}.js`;
return minify ? `${name}${suffix}.min.${ext}` : `${name}${suffix}.${ext}`;
},
},
cssTarget: ['chrome61'],
Expand Down
Loading

0 comments on commit d588656

Please sign in to comment.