Guest User

Untitled

a guest
May 25th, 2022
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. ```
  2. const path = require("path");
  3. const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
  4.  
  5. module.exports = {
  6. addons: [
  7. '@storybook/addon-actions',
  8. '@storybook/addon-viewport',
  9. ],
  10. stories: ["../src/c/components/**/*.stories.tsx"],
  11. presets: [path.resolve(__dirname, "./next-preset.js")],
  12. webpackFinal: async (config, { configType }) => {
  13. config.resolve.plugins = [new TsconfigPathsPlugin()];
  14. return config;
  15. }
  16. };
  17.  
  18. ```
  19.  
  20.  
  21. Content of next-preset.js
  22.  
  23. ```
  24. const path = require('path');
  25.  
  26. module.exports = {
  27. webpackFinal: async (baseConfig, options) => {
  28. const { module = {} } = baseConfig;
  29.  
  30. const newConfig = {
  31. ...baseConfig,
  32. module: {
  33. ...module,
  34. rules: [...(module.rules || [])],
  35. },
  36. };
  37.  
  38. // TypeScript
  39. newConfig.module.rules.push({
  40. test: /\.(ts|tsx)$/,
  41. include: [path.resolve(__dirname, '../src/c/components')],
  42. use: [
  43. {
  44. loader: 'babel-loader',
  45. options: {
  46. presets: ['next/babel', require.resolve('babel-preset-react-app')],
  47. plugins: ['react-docgen'],
  48. },
  49. },
  50. ],
  51. });
  52. newConfig.resolve.extensions.push('.ts', '.tsx');
  53.  
  54. // SCSS
  55. newConfig.module.rules.push({
  56. test: /\.(s*)css$/,
  57. loaders: ['style-loader', 'css-loader', 'sass-loader'],
  58. include: [
  59. path.resolve(__dirname, '../src/c/styles/globals.scss'),
  60. path.resolve(__dirname, '../')],
  61. });
  62.  
  63. // If you are using CSS Modules, check out the setup from Justin (justincy)
  64. // Many thanks to Justin for the inspiration
  65. // https://gist.github.com/justincy/b8805ae2b333ac98d5a3bd9f431e8f70#file-next-preset-js
  66.  
  67. return newConfig;
  68. },
  69. };
Advertisement
Add Comment
Please, Sign In to add comment