1 | // you can use this file to add your custom webpack plugins, loaders and anything you like.
|
2 | // This is just the basic way to add additional webpack configurations.
|
3 | // For more information refer the docs: https://storybook.js.org/configurations/custom-webpack-config
|
4 |
|
5 | // IMPORTANT
|
6 | // When you add this file, we won't add the default configurations which is similar
|
7 | // to "React Create App". This only has babel loader to load JavaScript.
|
8 |
|
9 | // module.exports = {
|
10 | // plugins: [
|
11 | // // your custom plugins
|
12 | // ],
|
13 | // module: {
|
14 | // rules: [
|
15 | // {
|
16 | // test: /\.css$/,
|
17 | // loader: 'style-loader!css-loader?modules&importLoaders=1!postcss-loader',
|
18 | // },
|
19 | // { test: /\.js$/, loader: 'babel-loader', include: /@integec\/grid-tools\/lib/ },
|
20 | // { test: /\.js$/, loader: 'babel-loader', include: /@integec\\grid-tools\\lib/ },
|
21 | // {
|
22 | // test: /\.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
|
23 | // use: ['file-loader'],
|
24 | // },
|
25 | // {
|
26 | // test: /\.stories\.jsx?$/,
|
27 | // loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
28 | // enforce: 'pre',
|
29 | // },
|
30 | // ],
|
31 | // },
|
32 | // }
|
33 | const path = require('path')
|
34 |
|
35 | // Export a function. Accept the base config as the only param.
|
36 | module.exports = (storybookBaseConfig, configType) => {
|
37 | // configType has a value of 'DEVELOPMENT' or 'PRODUCTION'
|
38 | // You can change the configuration based on that.
|
39 | // 'PRODUCTION' is used when building the static version of storybook.
|
40 |
|
41 | // Make whatever fine-grained changes you need
|
42 | //
|
43 | storybookBaseConfig.module.rules.push({
|
44 | test: /\.js$/,
|
45 | exclude: /node_modules/,
|
46 | loader: 'babel-loader',
|
47 | })
|
48 | storybookBaseConfig.module.rules.push({
|
49 | test: /\.css$/,
|
50 | loader: 'style-loader!css-loader?modules&importLoaders=1!postcss-loader',
|
51 | })
|
52 | storybookBaseConfig.module.rules.push({
|
53 | test: /\.(png|svg|jpg|gif|woff|woff2|eot|ttf|otf)$/,
|
54 | use: ['file-loader'],
|
55 | })
|
56 | storybookBaseConfig.module.rules.push({
|
57 | test: /\.stories\.jsx?$/,
|
58 | loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
59 | enforce: 'pre',
|
60 | })
|
61 |
|
62 | storybookBaseConfig.resolve = {
|
63 | extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
64 | alias: {
|
65 | react: path.resolve(path.join(__dirname, '../node_modules/react')),
|
66 | 'react-popper': path.resolve(path.join(__dirname, '../node_modules/react-popper')),
|
67 | },
|
68 | }
|
69 |
|
70 | // Return the altered config
|
71 | return storybookBaseConfig
|
72 | }
|