@pure-ds/storybook 0.3.15 → 0.3.17

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 +11 -5
  2. package/package.json +1 -1
@@ -160,21 +160,27 @@ const config = {
160
160
  }
161
161
 
162
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.
163
+ // Vite blocks direct imports from public/, so we disable Vite's public directory
164
+ // handling (Storybook uses staticDirs instead) and resolve these imports ourselves.
165
165
  const userPublicPath = resolve(process.cwd(), 'public');
166
166
  const isConsumerProject = process.cwd() !== resolve(currentDirname, '..');
167
167
 
168
168
  if (isConsumerProject && fs.existsSync(userPublicPath)) {
169
+ // Disable Vite's public directory to prevent "Cannot import non-asset file" errors
170
+ // Storybook's staticDirs handles serving public files at runtime
171
+ config.publicDir = false;
172
+
169
173
  config.plugins = config.plugins || [];
170
- config.plugins.push({
174
+ // Insert at the beginning to run before other plugins
175
+ config.plugins.unshift({
171
176
  name: 'pds-public-esm-loader',
172
- resolveId(id) {
177
+ enforce: 'pre', // Run before Vite's built-in plugins
178
+ resolveId(id, importer) {
173
179
  // Handle absolute paths starting with /assets/ or other paths in public
174
180
  if (id.startsWith('/') && !id.startsWith('/@') && !id.startsWith('/node_modules')) {
175
181
  const filePath = resolve(userPublicPath, id.slice(1)); // Remove leading /
176
182
  if (fs.existsSync(filePath) && (filePath.endsWith('.js') || filePath.endsWith('.mjs'))) {
177
- // Return a virtual module ID
183
+ // Return a virtual module ID to bypass Vite's public folder check
178
184
  return `\0virtual:public-esm:${id}`;
179
185
  }
180
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pure-ds/storybook",
3
- "version": "0.3.15",
3
+ "version": "0.3.17",
4
4
  "description": "Storybook showcase for Pure Design System with live configuration",
5
5
  "type": "module",
6
6
  "private": false,