generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
razzle.extend.js
43 lines (35 loc) · 1.49 KB
/
razzle.extend.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
const path = require('path');
const makeLoaderFinder = require('razzle-dev-utils/makeLoaderFinder');
const babelLoaderFinder = makeLoaderFinder('babel-loader');
const plugins = (defaultPlugins) => {
return defaultPlugins;
};
const modify = (config, { target, dev }, webpack) => {
const themeConfigPath = `${__dirname}/theme/theme.config`;
config.resolve.alias['../../theme.config$'] = themeConfigPath;
config.resolve.alias['../../theme.config'] = themeConfigPath;
config.resolve.alias['../../theme'] = `${__dirname}/theme`;
const projectRootPath = path.resolve('.');
const themeLessPath = `${projectRootPath}/node_modules/@eeacms/volto-eea-design-system/theme`;
config.resolve.alias['eea-design-system-theme'] = dev
? `${projectRootPath}/src/addons/volto-eea-design-system/theme/themes/eea`
: `${themeLessPath}/themes/eea`;
const semanticLessPath = `${projectRootPath}/node_modules/semantic-ui-less`;
const hasDesignSystemInstalled = config.resolve.alias['eea-volto-themes'];
config.resolve.alias['eea-volto-theme-folder'] = hasDesignSystemInstalled
? themeLessPath
: semanticLessPath;
const babelLoader = config.module.rules.find(babelLoaderFinder);
const sanitizePath = path.join(
path.dirname(require.resolve('sanitize-html')),
);
const { include } = babelLoader;
const htmlParserPath = `${sanitizePath}/node_modules/htmlparser2/lib/esm/`;
include.push(sanitizePath);
include.push(htmlParserPath);
return config;
};
module.exports = {
plugins,
modify,
};