From 0b02f646937eff7c39b0b430554ce46bc5273615 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 23 Jun 2020 16:49:46 -0500 Subject: [PATCH] Add example storybook --- .storybook/main.js | 33 +++++++++++++++++++++++++------- app/javascript/stories/index.jsx | 15 +++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 app/javascript/stories/index.jsx diff --git a/.storybook/main.js b/.storybook/main.js index 3902cf2a..54b8f3fa 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -1,9 +1,28 @@ -module.exports = { - stories: ['../stories/**/*.stories.js'], - addons: ['@storybook/addon-actions', '@storybook/addon-links'], - webpackFinal: async config => { - // do mutation to the config +// License: LGPL-3.0-or-later +// Based on https://github.com/rails/webpacker/issues/1004#issuecomment-628377930 +process.env.NODE_ENV = "development"; +const railsWebpackEnv = require("../config/webpack/environment"); - return config; - }, +module.exports = { + stories: ["../app/javascript/stories/*.[tj]s?(x)"], + addons: ['@storybook/addon-actions', '@storybook/addon-links'], + webpackFinal: (config) => ({ + // do mutation to the config + ...config, + resolve: { + ...config.resolve, + ...railsWebpackEnv.config.resolve, + modules: railsWebpackEnv.resolvedModules.map((i) => i.value), + }, + module: { + ...config.module, + rules: railsWebpackEnv.loaders + .filter((i) => i.key !== "nodeModules") + .map((i) => i.value), + }, + plugins: [ + ...config.plugins, + ...railsWebpackEnv.plugins.map((i) => i.value), + ], + }), }; diff --git a/app/javascript/stories/index.jsx b/app/javascript/stories/index.jsx new file mode 100644 index 00000000..d9bd3246 --- /dev/null +++ b/app/javascript/stories/index.jsx @@ -0,0 +1,15 @@ +// License: LGPL-3.0-or-later +import React from 'react'; +import { Button } from '@storybook/react/demo'; + +export default { title: 'Button' }; + +export const withText = () => ; + +export const withEmoji = () => ( + +); \ No newline at end of file