-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcarbonio.webpack.js
More file actions
56 lines (47 loc) · 1.39 KB
/
carbonio.webpack.js
File metadata and controls
56 lines (47 loc) · 1.39 KB
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
/*
* SPDX-FileCopyrightText: 2025 Zextras <https://www.zextras.com>
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { execSync } = require('child_process');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const customizeConfig = (config, pkg) => {
const newConfig = { ...config };
const commitHash = execSync('git rev-parse HEAD').toString().trim();
const packageName = pkg.name || require(path.resolve(__dirname, 'package.json')).name;
const baseStaticPath = `/static/iris/${packageName}/${commitHash}/`;
newConfig.resolve = {
...config.resolve,
alias: {
...(config.resolve?.alias || {}),
'app-entrypoint': path.resolve(__dirname, 'src/app.tsx')
},
modules: [path.resolve(__dirname, 'src'), 'node_modules']
};
newConfig.plugins = newConfig.plugins || [];
newConfig.plugins.push(
new webpack.DefinePlugin({
BASE_PATH: JSON.stringify(baseStaticPath)
})
);
newConfig.plugins.push(
new CopyPlugin({
patterns: [
{
from: path.resolve(
__dirname,
'node_modules/@zextras/carbonio-ui-text-composer/dist/assets'
),
to: path.resolve(__dirname, 'dist/'),
noErrorOnMissing: true
}
]
})
);
return newConfig;
};
// Still required to keep the compatibility with the sdk
module.exports = customizeConfig;