Skip to content

Commit b744c4f

Browse files
External webpack-config for Storybook
1 parent d7de7f4 commit b744c4f

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

.storybook/main.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
const webpackConfig = require('../webpack-config.js')
2+
const path = require('path');
13
module.exports = {
24
"stories": ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
35
"addons": ["@storybook/addon-links", "@storybook/addon-essentials"],
46
"framework": "@storybook/vue3",
57
core: {
68
builder: "webpack5"
9+
},
10+
"webpackFinal": async(cfg, {configType}) => {
11+
cfg.module.rules.push({
12+
test: /\.(styl|stylus)$/,
13+
use: ['style-loader', 'css-loader', 'stylus-loader'],
14+
});
15+
cfg = webpackConfig(cfg)
16+
// cfg.plugins.push(
17+
// new ESLintPlugin(options)
18+
// )
19+
// cfg.plugins.push(new ESLintPlugin({
20+
// extensions: [ 'js', 'vue' ],
21+
// fix: true,
22+
// formatter: 'stylish',
23+
// threads: false
24+
// }))
25+
return cfg;
726
}
8-
};
27+
};

webpack-config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const path = require('path')
2+
const ESLintPlugin = require('eslint-webpack-plugin')
3+
4+
const options = {
5+
extensions: [`js`, `vue`],
6+
exclude: [
7+
'node_modules/',
8+
'.storybook'
9+
],
10+
fix: true,
11+
formatter: 'stylish',
12+
threads: false
13+
}
14+
15+
module.exports = (cfg) => {
16+
cfg.module.rules.push({
17+
test: /\.pug$/,
18+
loader: 'pug-plain-loader'
19+
})
20+
cfg.resolve.alias = {
21+
...cfg.resolve.alias,
22+
'~': path.resolve(__dirname, 'src')
23+
}
24+
25+
cfg.plugins.push(
26+
new ESLintPlugin(options)
27+
)
28+
29+
return cfg
30+
}

0 commit comments

Comments
 (0)