2021-04-28 21:53:59 +02:00
|
|
|
const path = require('path');
|
2020-11-30 21:10:46 +01:00
|
|
|
|
2022-11-29 19:23:36 +01:00
|
|
|
const { ProvidePlugin } = require('webpack');
|
2021-04-28 21:53:59 +02:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2020-11-30 21:10:46 +01:00
|
|
|
|
2022-09-20 19:15:14 +02:00
|
|
|
const { generateIconNames } = require('../development/generate-icon-names');
|
|
|
|
|
2020-02-26 14:34:59 +01:00
|
|
|
module.exports = {
|
2022-11-29 19:23:36 +01:00
|
|
|
core: {
|
|
|
|
builder: 'webpack5',
|
|
|
|
},
|
2023-01-20 20:27:46 +01:00
|
|
|
features: { buildStoriesJson: true },
|
2022-01-07 21:30:37 +01:00
|
|
|
stories: [
|
|
|
|
'../ui/**/*.stories.js',
|
2023-03-08 18:35:16 +01:00
|
|
|
'../ui/**/*.stories.tsx',
|
2022-01-07 21:30:37 +01:00
|
|
|
'../ui/**/*.stories.mdx',
|
|
|
|
'./*.stories.mdx',
|
|
|
|
],
|
2020-02-26 14:34:59 +01:00
|
|
|
addons: [
|
2021-10-29 19:22:07 +02:00
|
|
|
'@storybook/addon-essentials',
|
2020-02-26 14:34:59 +01:00
|
|
|
'@storybook/addon-actions',
|
2021-10-29 19:22:07 +02:00
|
|
|
'@storybook/addon-a11y',
|
|
|
|
'@storybook/addon-knobs',
|
2021-02-08 16:45:06 +01:00
|
|
|
'./i18n-party-addon/register.js',
|
2022-02-25 23:11:22 +01:00
|
|
|
'storybook-dark-mode',
|
2023-03-10 18:47:01 +01:00
|
|
|
'@whitespace/storybook-addon-html'
|
2020-02-26 14:34:59 +01:00
|
|
|
],
|
2022-09-07 00:58:22 +02:00
|
|
|
staticDirs: ['../app', './images'],
|
2021-10-29 19:22:07 +02:00
|
|
|
// Uses babel.config.js settings and prevents "Missing class properties transform" error
|
|
|
|
babel: async (options) => ({ overrides: options.overrides }),
|
2022-09-20 19:15:14 +02:00
|
|
|
// Sets env variables https://storybook.js.org/docs/react/configure/environment-variables/
|
|
|
|
env: async (config) => {
|
|
|
|
return {
|
|
|
|
...config,
|
|
|
|
// Creates the icon names environment variable for the component-library/icon/icon.js component
|
2022-12-15 23:46:30 +01:00
|
|
|
ICON_NAMES: generateIconNames(),
|
2022-09-20 19:15:14 +02:00
|
|
|
};
|
|
|
|
},
|
2020-11-30 21:10:46 +01:00
|
|
|
webpackFinal: async (config) => {
|
2021-10-29 19:22:07 +02:00
|
|
|
config.context = process.cwd();
|
2021-09-15 20:55:48 +02:00
|
|
|
config.node = {
|
2021-10-29 19:22:07 +02:00
|
|
|
__filename: true,
|
|
|
|
};
|
2022-09-07 00:58:22 +02:00
|
|
|
config.resolve.alias['webextension-polyfill'] = require.resolve(
|
2023-02-11 01:03:28 +01:00
|
|
|
'../ui/__mocks__/webextension-polyfill.js',
|
2022-09-07 00:58:22 +02:00
|
|
|
);
|
2022-11-29 19:23:36 +01:00
|
|
|
config.resolve.fallback = {
|
|
|
|
child_process: false,
|
|
|
|
constants: false,
|
|
|
|
crypto: false,
|
|
|
|
fs: false,
|
|
|
|
http: false,
|
|
|
|
https: false,
|
|
|
|
os: false,
|
|
|
|
path: false,
|
|
|
|
stream: require.resolve('stream-browserify'),
|
|
|
|
_stream_transform: false,
|
|
|
|
};
|
2021-04-28 21:53:59 +02:00
|
|
|
config.module.strictExportPresence = true;
|
2020-11-30 21:10:46 +01:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.scss$/,
|
2022-11-29 19:23:36 +01:00
|
|
|
use: [
|
2020-11-30 21:10:46 +01:00
|
|
|
'style-loader',
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
import: false,
|
|
|
|
url: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
2021-01-19 17:54:32 +01:00
|
|
|
implementation: require('sass'),
|
2021-01-20 16:58:03 +01:00
|
|
|
sassOptions: {
|
2021-04-28 21:53:59 +02:00
|
|
|
includePaths: ['ui/css/'],
|
2021-01-20 16:58:03 +01:00
|
|
|
},
|
2020-11-30 21:10:46 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-04-28 21:53:59 +02:00
|
|
|
});
|
2021-01-19 17:54:32 +01:00
|
|
|
config.plugins.push(
|
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.join(
|
|
|
|
'node_modules',
|
|
|
|
'@fortawesome',
|
|
|
|
'fontawesome-free',
|
|
|
|
'webfonts',
|
|
|
|
),
|
|
|
|
to: path.join('fonts', 'fontawesome'),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2021-04-28 21:53:59 +02:00
|
|
|
);
|
2022-11-29 19:23:36 +01:00
|
|
|
config.plugins.push(
|
|
|
|
new ProvidePlugin({
|
|
|
|
Buffer: ['buffer', 'Buffer'],
|
|
|
|
}),
|
2022-12-15 23:46:30 +01:00
|
|
|
);
|
2021-04-28 21:53:59 +02:00
|
|
|
return config;
|
2020-11-30 21:10:46 +01:00
|
|
|
},
|
2021-04-28 21:53:59 +02:00
|
|
|
};
|