-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.js
78 lines (73 loc) · 2.85 KB
/
main.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
67
68
69
70
71
72
73
74
75
76
77
78
const { extendWebpackConfig } = require("../packages/@vulcanjs/webpack");
const debug = require("debug");
const debugWebpack = debug("vns:webpack");
const path = require("path");
const plugins = [];
if (process.env.ANALYZE === "true") {
debugWebpack("Enabling bundle analysis for Storybook"); // eslint-disable-line no-console
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
plugins.push(new BundleAnalyzerPlugin());
}
module.exports = {
stories: [
"../stories/0-Welcome.stories.js",
// "../stories/**/*.stories.@(js|ts|jsx|tsx|mdx)",
// "../src/**/*.stories.@(js|ts|jsx|tsx|mdx)",
],
addons: [
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-docs", // it seems that MDX is enabled as a default
// "@storybook/addon-contexts", // TODO: waiting for v6.0.0 to be released
"@storybook/addon-backgrounds",
// "@storybook/addon-knobs", // Knob is not installed as a default anymore, we prefer to use the more intuitive "controls" addon
// @see https://medium.com/storybookjs/storybook-controls-ce82af93e430
"@storybook/addon-controls",
"@storybook/addon-a11y",
],
typescript: {
reactDocgen: false,
},
babel: async (config) => {
config.presets.push([
"next/babel",
{
"styled-jsx": {
plugins: ["styled-jsx-plugin-postcss"],
},
},
]);
console.log(config);
return config;
},
// https://github.com/storybookjs/storybook/blob/next/docs/src/pages/configurations/custom-webpack-config/index.md#debug-the-default-webpack-config
webpackFinal: async (config, { configType }) => {
// add magic imports and isomorphic imports to Storybook
const withVulcan = extendWebpackConfig("client")(config);
// add mdx support, in components
// @see https://mdxjs.com/getting-started/webpack
withVulcan.module.rules.push({
test: /\.mdx?$/,
exclude: /\.stories.mdx?$/, // ignore stories themselves, that should be handled by addon-docs
use: ["babel-loader", "@mdx-js/loader"],
});
// Bypass interference with Storybook doc, which already set a conflicting rule for .md import
// @see https://github.com/storybookjs/storybook/issues/7644#issuecomment-592536159
withVulcan.module.rules = [
...withVulcan.module.rules.filter(
(rule) => rule.test.source !== "\\.md$"
),
];
// add mocks for NPM imports, eg next/router and next/config
withVulcan.resolve.alias = {
...(withVulcan.resolve.alias || {}),
"next/config": path.join(__dirname, "./mocks/packages/next-config.js"),
"next/router": path.join(__dirname, "./mocks/packages/next-router.js"),
};
// load optional plugins (eg bundle analyzer)
withVulcan.plugins = (withVulcan.plugins || []).concat(plugins);
return withVulcan;
},
};