-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.storybook.js
50 lines (48 loc) · 1.44 KB
/
webpack.storybook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const path = require('node:path')
const MiniCSSExtractPlugin = require('mini-css-extract-plugin')
const common = require('./webpack/webpack.common.js')()
// Looks a bit convoluted but I think that's fine for now
module.exports = (storybookConfig, mode) => ({
...storybookConfig,
resolve: {
...storybookConfig.resolve,
plugins: common.resolve.plugins,
},
plugins: [
...storybookConfig.plugins,
mode === 'production' && new MiniCSSExtractPlugin({ filename: '[name].[contenthash].css' }),
].filter(Boolean),
module: {
rules: [
...common.module.rules,
{
test: /\.[jt]sx?$/,
include: [path.resolve(__dirname, './src'), path.resolve(__dirname, './.storybook')],
use: {
loader: 'babel-loader',
options: {
envName: mode === 'development' ? 'storybookDev' : 'production',
// Shouldn't be necessary with webpack cache, right?
// Test performance impact
cacheDirectory: '.cache/storybook/babel-loader',
cacheCompression: false,
},
},
},
{
test: /\.css$/,
use: [
mode === 'development' ? 'style-loader' : MiniCSSExtractPlugin.loader,
'css-loader',
].filter(Boolean),
},
],
},
cache: {
type: 'filesystem',
cacheDirectory: path.resolve(__dirname, './.cache/storybook/webpack'),
buildDependencies: {
config: [__filename],
},
},
})