forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas_webpack.ts
71 lines (68 loc) · 2.01 KB
/
canvas_webpack.ts
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
67
68
69
70
71
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { resolve } from 'path';
import { defaultConfig, mergeWebpackFinal } from '@kbn/storybook';
import type { StorybookConfig } from '@kbn/storybook';
import { KIBANA_ROOT } from './constants';
export const canvasWebpack = {
module: {
rules: [
// Enable CSS Modules in Storybook (Shareable Runtime)
{
test: /\.module\.s(a|c)ss$/,
loader: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 2,
modules: {
localIdentName: '[name]__[local]___[hash:base64:5]',
},
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
config: resolve(KIBANA_ROOT, 'packages/kbn-optimizer/postcss.config.js'),
},
},
},
{
loader: 'sass-loader',
options: {
implementation: require('node-sass'),
},
},
],
},
// Exclude large-dependency, troublesome or irrelevant modules.
{
test: [
resolve(KIBANA_ROOT, 'x-pack/plugins/canvas/public/components/embeddable_flyout'),
resolve(KIBANA_ROOT, 'x-pack/plugins/reporting/public'),
],
use: 'null-loader',
},
],
},
resolve: {
alias: {
'src/plugins': resolve(KIBANA_ROOT, 'src/plugins'),
'../../lib/es_service': resolve(
KIBANA_ROOT,
'x-pack/plugins/canvas/storybook/__mocks__/es_service.ts'
),
},
},
};
export const canvasStorybookConfig: StorybookConfig = {
...defaultConfig,
addons: [...(defaultConfig.addons || []), require.resolve('./addon/register')],
...mergeWebpackFinal(canvasWebpack),
};