tmeasday / storybook-skeleton

3 stars 1 forks source link

Refactor skeleton to be contained inside running project #26

Closed tmeasday closed 3 years ago

tmeasday commented 3 years ago

Rather than symlinking the project inside the skeleton and running with PROJECT=x instead:

  1. Symlink the skeleton inside the project
  2. Set the webpack config in .storybook/main.js:skeletonWebpackConfig
  3. We automatically generate stories.json (cf https://github.com/tmeasday/storybook-skeleton/issues/22)
  4. We automatically generate an import function (no more need for import aliases).

See the README for more details.

Doing things this way relies on the app's FS structure and node_modules more, which was required to get it running in Shopify's projects.

tmeasday commented 3 years ago

I wonder if it would be possible to replace the require.context code with import() as that would work with lazy compilation. If not, then we'll have to figure out a fix on webpack side with Tobias.

Sorry, yeah I haven't had a moment to try it just yet (will do later tonight or tomorrow!). I have tested that you can make a path based import(), and it would be easy enough to create a new "import style" based on that.

tmeasday commented 3 years ago

@bebraw I added dynamic and lazy-dynamic import modes that map './path/*/.stories.js' to:

require(`./path/${X}.stories.js`);
import(`./path/${X}.stories.js`);

respectively.

Best of all I confirmed the latter works with COMPILE_LAZILY=1, nice job.

tmeasday commented 3 years ago

Going to merge this, hope that's OK!