-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.js
52 lines (39 loc) · 1.84 KB
/
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
const path = require('path');
const TARGET_DIR = process.cwd();
const PROJECT_DIR = __dirname;
const defaultStoriesConfig = {
storybookDir: '.storybook',
webpackConfig: 'webpack.config.js',
storiesMask: '**/*.story.js',
ignore: 'node_modules/**/*',
setupFile: 'additional.js',
previewHeader: 'preview-header.html',
middlewaresFile: 'middlewares.js',
};
const customStoriesConfig = require(path.resolve(TARGET_DIR, 'package.json'))['storybook'] || {};
Object.keys(customStoriesConfig).forEach((key) => {
!!defaultStoriesConfig[key] && console.log(
`using custom setting ${key}: ${customStoriesConfig[key]}`
);
});
const storiesConfig = Object.assign({}, defaultStoriesConfig, customStoriesConfig);
const STORYBOOK_DIR = path.resolve(TARGET_DIR, storiesConfig.storybookDir);
module.exports = {
stories: storiesConfig,
paths: {
TARGET_DIR: TARGET_DIR,
PROJECT_DIR: PROJECT_DIR,
STORYBOOK_DIR: STORYBOOK_DIR,
TARGET_NODE_MODULES: path.resolve(TARGET_DIR, 'node_modules'),
PROJECT_NODE_MODULES: path.resolve(PROJECT_DIR, 'node_modules'),
CUSTOM_WEBPACK_CONFIG: path.resolve(TARGET_DIR, storiesConfig.storybookDir, storiesConfig.webpackConfig),
DEFAULT_WEBPACK_CONFIG: path.resolve(PROJECT_DIR, 'defaults/webpack.config.js'),
CUSTOM_PREVIEW_HEADER: path.resolve(TARGET_DIR, storiesConfig.storybookDir, storiesConfig.previewHeader),
SETUP_FILE: path.resolve(TARGET_DIR, storiesConfig.storybookDir, storiesConfig.setupFile),
MIDDLEWARES_FILE: path.resolve(TARGET_DIR, storiesConfig.storybookDir, storiesConfig.middlewaresFile),
MANAGER_APP: path.resolve(PROJECT_DIR, 'js/manager.js'),
PREVIEW_APP: path.resolve(PROJECT_DIR, 'js/preview.js'),
FAVICON_FILE: path.resolve(TARGET_DIR, storiesConfig.storybookDir, 'favicon.ico'),
FALLBACK_FAVICON_FILE: path.resolve(PROJECT_DIR, 'favicon.ico'),
}
}