-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmain.js
72 lines (67 loc) · 2.1 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
const path = require("path");
const clientConfig = require("preact-cli/lib/lib/webpack/webpack-client-config");
const transformConfig = require("preact-cli/lib/lib/webpack/transform-config");
module.exports = {
framework: "@storybook/preact",
stories: [
"../stories/**/*stories.js",
"../stories/**/*stories.ts",
"../plugins/**/*stories.js",
"../plugins/**/*stories.ts",
],
addons: [
"@storybook/addon-actions",
"@storybook/addon-controls",
"@storybook/addon-essentials",
],
features: {
interactionsDebugger: true,
},
webpackFinal: async (config, { configType }) => {
// Load preact config
const isProd = configType === "PRODUCTION";
const cwd = process.env.PWD;
const src = path.resolve(cwd, "src");
const source = (dir) => path.resolve(cwd, "src", dir);
const env = {
isProd,
isWatch: !isProd,
cwd,
src,
source,
config: "preact.config.js",
esm: false,
};
preactConfig = await clientConfig(env);
await transformConfig(env, preactConfig);
// Add custom alias
config.resolve.alias = {
...config.resolve.alias,
...preactConfig.resolve.alias,
};
// Add proxy
config.devServer = {
...config.devServer,
...preactConfig.devServer,
};
// Parse .less files
config.resolve.extensions.push(".less");
config.module.rules.push({
test: /\.(p?css|less|s[ac]ss|styl)$/,
use: [
require.resolve("style-loader"),
{
loader: require.resolve("css-loader"),
options: {
importLoaders: 1,
modules: {
localIdentName: "[name]__[local]___[hash:base64:5]",
},
},
},
require.resolve("less-loader"),
],
});
return config;
},
};