Fix unnecessary duplication in vite code for finding entrypoints (#35515)
This commit is contained in:
@@ -189,11 +189,11 @@ async function findEntrypoints() {
|
|||||||
const entrypoints: Record<string, string> = {};
|
const entrypoints: Record<string, string> = {};
|
||||||
|
|
||||||
// First, JS entrypoints
|
// First, JS entrypoints
|
||||||
const jsEntrypoints = await readdir(path.resolve(jsRoot, 'entrypoints'), {
|
const jsEntrypointsDir = path.resolve(jsRoot, 'entrypoints');
|
||||||
|
const jsEntrypoints = await readdir(jsEntrypointsDir, {
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
});
|
});
|
||||||
const jsExtTest = /\.[jt]sx?$/;
|
const jsExtTest = /\.[jt]sx?$/;
|
||||||
const jsEntrypointsDir = path.resolve(jsRoot, 'entrypoints');
|
|
||||||
for (const file of jsEntrypoints) {
|
for (const file of jsEntrypoints) {
|
||||||
if (file.isFile() && jsExtTest.test(file.name)) {
|
if (file.isFile() && jsExtTest.test(file.name)) {
|
||||||
entrypoints[file.name.replace(jsExtTest, '')] = path.resolve(
|
entrypoints[file.name.replace(jsExtTest, '')] = path.resolve(
|
||||||
@@ -204,12 +204,11 @@ async function findEntrypoints() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next, SCSS entrypoints
|
// Next, SCSS entrypoints
|
||||||
const scssEntrypoints = await readdir(
|
|
||||||
path.resolve(jsRoot, 'styles/entrypoints'),
|
|
||||||
{ withFileTypes: true },
|
|
||||||
);
|
|
||||||
const scssExtTest = /\.s?css$/;
|
|
||||||
const scssEntrypointsDir = path.resolve(jsRoot, 'styles/entrypoints');
|
const scssEntrypointsDir = path.resolve(jsRoot, 'styles/entrypoints');
|
||||||
|
const scssEntrypoints = await readdir(scssEntrypointsDir, {
|
||||||
|
withFileTypes: true,
|
||||||
|
});
|
||||||
|
const scssExtTest = /\.s?css$/;
|
||||||
for (const file of scssEntrypoints) {
|
for (const file of scssEntrypoints) {
|
||||||
if (file.isFile() && scssExtTest.test(file.name)) {
|
if (file.isFile() && scssExtTest.test(file.name)) {
|
||||||
entrypoints[file.name.replace(scssExtTest, '')] = path.resolve(
|
entrypoints[file.name.replace(scssExtTest, '')] = path.resolve(
|
||||||
|
|||||||
Reference in New Issue
Block a user