@pure-ds/storybook 0.3.12 → 0.3.14
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 +21 -2
- package/package.json +1 -1
package/.storybook/main.js
CHANGED
|
@@ -20,9 +20,10 @@ const config = {
|
|
|
20
20
|
? normalizePath(resolve(process.env.PDS_STORIES_PATH, '**/*.stories.@(js|jsx|mjs|ts|tsx)'))
|
|
21
21
|
: '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
22
22
|
// Include user stories from the project root, but only if we are NOT running in the package itself
|
|
23
|
-
...(process.cwd() === resolve(
|
|
23
|
+
...(process.cwd() === resolve(currentDirname, '..') ? [] : [
|
|
24
24
|
normalizePath(resolve(process.cwd(), 'stories/**/*.stories.@(js|jsx|mjs|ts|tsx)')),
|
|
25
|
-
normalizePath(resolve(process.cwd(), 'src/**/*.stories.@(js|jsx|mjs|ts|tsx)'))
|
|
25
|
+
normalizePath(resolve(process.cwd(), 'src/**/*.stories.@(js|jsx|mjs|ts|tsx)')),
|
|
26
|
+
normalizePath(resolve(process.cwd(), 'public/**/*.stories.@(js|jsx|mjs|ts|tsx)'))
|
|
26
27
|
])
|
|
27
28
|
],
|
|
28
29
|
addons: [
|
|
@@ -158,6 +159,24 @@ const config = {
|
|
|
158
159
|
config.resolve.alias['@user/pds-config'] = resolve(currentDirname, '../default-pds.config.js');
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
// Support absolute path imports from user's public folder
|
|
163
|
+
// This allows stories to use imports like: import { html } from '/assets/js/lit.js';
|
|
164
|
+
const userPublicPath = resolve(process.cwd(), 'public');
|
|
165
|
+
if (process.cwd() !== resolve(currentDirname, '..') && fs.existsSync(userPublicPath)) {
|
|
166
|
+
const userAssetsPath = resolve(userPublicPath, 'assets');
|
|
167
|
+
if (fs.existsSync(userAssetsPath)) {
|
|
168
|
+
config.resolve.alias['/assets'] = userAssetsPath;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Allow Vite to serve files from user's public folder
|
|
172
|
+
config.server = config.server || {};
|
|
173
|
+
config.server.fs = config.server.fs || {};
|
|
174
|
+
config.server.fs.allow = [
|
|
175
|
+
...(config.server.fs.allow || []),
|
|
176
|
+
userPublicPath
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
|
|
161
180
|
// Set base path for production builds
|
|
162
181
|
if (config.mode === 'production') {
|
|
163
182
|
config.base = '/storybook/';
|