@pure-ds/storybook 0.3.14 → 0.3.15
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/.storybook/main.js +30 -15
- package/package.json +1 -1
package/.storybook/main.js
CHANGED
|
@@ -159,22 +159,37 @@ const config = {
|
|
|
159
159
|
config.resolve.alias['@user/pds-config'] = resolve(currentDirname, '../default-pds.config.js');
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
// Support absolute path imports from
|
|
163
|
-
//
|
|
162
|
+
// Support absolute path imports like: import { html } from '/assets/js/lit.js';
|
|
163
|
+
// Vite blocks direct imports from public/, so we use a plugin that serves
|
|
164
|
+
// the file contents as virtual modules, bypassing Vite's public folder restriction.
|
|
164
165
|
const userPublicPath = resolve(process.cwd(), 'public');
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
const isConsumerProject = process.cwd() !== resolve(currentDirname, '..');
|
|
167
|
+
|
|
168
|
+
if (isConsumerProject && fs.existsSync(userPublicPath)) {
|
|
169
|
+
config.plugins = config.plugins || [];
|
|
170
|
+
config.plugins.push({
|
|
171
|
+
name: 'pds-public-esm-loader',
|
|
172
|
+
resolveId(id) {
|
|
173
|
+
// Handle absolute paths starting with /assets/ or other paths in public
|
|
174
|
+
if (id.startsWith('/') && !id.startsWith('/@') && !id.startsWith('/node_modules')) {
|
|
175
|
+
const filePath = resolve(userPublicPath, id.slice(1)); // Remove leading /
|
|
176
|
+
if (fs.existsSync(filePath) && (filePath.endsWith('.js') || filePath.endsWith('.mjs'))) {
|
|
177
|
+
// Return a virtual module ID
|
|
178
|
+
return `\0virtual:public-esm:${id}`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
load(id) {
|
|
183
|
+
if (id.startsWith('\0virtual:public-esm:')) {
|
|
184
|
+
const originalPath = id.replace('\0virtual:public-esm:', '');
|
|
185
|
+
const filePath = resolve(userPublicPath, originalPath.slice(1));
|
|
186
|
+
if (fs.existsSync(filePath)) {
|
|
187
|
+
// Read and return the actual file contents
|
|
188
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
178
193
|
}
|
|
179
194
|
|
|
180
195
|
// Set base path for production builds
|