@pure-ds/storybook 0.3.13 → 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.
Files changed (2) hide show
  1. package/.storybook/main.js +33 -0
  2. package/package.json +1 -1
@@ -159,6 +159,39 @@ 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 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.
165
+ const userPublicPath = resolve(process.cwd(), 'public');
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
+ });
193
+ }
194
+
162
195
  // Set base path for production builds
163
196
  if (config.mode === 'production') {
164
197
  config.base = '/storybook/';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pure-ds/storybook",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "Storybook showcase for Pure Design System with live configuration",
5
5
  "type": "module",
6
6
  "private": false,