-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
66 lines (60 loc) · 1.76 KB
/
webpack.config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
This config allows Storybook to use its default webpack config, with slight modifications
*/
const path = require('path');
const postcssPresetEnv = require('postcss-preset-env');
module.exports = ({ config }) => {
// a bit of a hack to remove svg handling from Storybook's default webpack config:
// find the rule that matches svg files and replace its regex with Storybook's default,
// but without svg
const defaultSvgRule = config.module.rules.find(rule => rule.test.test('.svg'));
defaultSvgRule.test = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|cur|ani)(\?.*)?$/;
config.module.rules.push({
test: /\.tsx?$/,
loader: require.resolve('babel-loader'),
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../stories'),
path.resolve(__dirname, '../tests'),
]
});
config.module.rules.push({
test: /.scss$/,
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../stories'),
],
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: {
localIdentName: '[local]__[name]__[hash:base64:5]'
}
}
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [postcssPresetEnv()]
}
},
'sass-loader'
]
});
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack', 'file-loader'],
});
config.resolve.extensions.push('.ts', '.tsx');
config.resolve.alias = {
config: path.join(__dirname, '../config.ts'),
src: path.join(__dirname, '../src'),
tests: path.join(__dirname, '../tests'),
static: path.join(__dirname, '../static')
};
return config;
};