rails-vite-plugin 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -134,9 +134,13 @@ function prefixWithSourceDir(entry, sourceDir) {
|
|
|
134
134
|
}
|
|
135
135
|
return `${sourceDir}/${entry}`;
|
|
136
136
|
}
|
|
137
|
-
const
|
|
137
|
+
const entrypointExtensions = /\.(mjs|js|mts|ts|jsx|tsx|css|scss|sass|less|styl|pcss)$/;
|
|
138
138
|
function detectEntrypoint(sourceDir) {
|
|
139
|
-
|
|
139
|
+
const entrypointsDir = path.join(sourceDir, 'entrypoints');
|
|
140
|
+
if (fs.existsSync(entrypointsDir)) {
|
|
141
|
+
return discoverEntrypoints(entrypointsDir).map((entry) => `entrypoints/${entry}`);
|
|
142
|
+
}
|
|
143
|
+
for (const ext of ['.js', '.mjs', '.ts', '.mts', '.jsx', '.tsx']) {
|
|
140
144
|
const candidate = path.join(sourceDir, `application${ext}`);
|
|
141
145
|
if (fs.existsSync(candidate)) {
|
|
142
146
|
return `application${ext}`;
|
|
@@ -144,6 +148,18 @@ function detectEntrypoint(sourceDir) {
|
|
|
144
148
|
}
|
|
145
149
|
return 'application.js';
|
|
146
150
|
}
|
|
151
|
+
function discoverEntrypoints(dir, base = dir) {
|
|
152
|
+
const entries = [];
|
|
153
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
154
|
+
if (entry.isDirectory()) {
|
|
155
|
+
entries.push(...discoverEntrypoints(path.join(dir, entry.name), base));
|
|
156
|
+
}
|
|
157
|
+
else if (entrypointExtensions.test(entry.name)) {
|
|
158
|
+
entries.push(path.relative(base, path.join(dir, entry.name)));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return entries;
|
|
162
|
+
}
|
|
147
163
|
function resolveRefreshPaths(refresh) {
|
|
148
164
|
if (refresh === false)
|
|
149
165
|
return [];
|