-
Notifications
You must be signed in to change notification settings - Fork 43
/
webpack.config.js
43 lines (40 loc) · 1.38 KB
/
webpack.config.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 fs = require('fs');
const path = require('path');
const { DefinePlugin } = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const packageinfo = require('./package.json');
module.exports.getWebpackConfig = (config, options) => {
const hasEngREADME = fs.existsSync(path.resolve(process.cwd(), 'src', 'README.en-US.md'));
const customWebpackConfig = {
...config,
context: path.join(__dirname, 'src'),
entry: {
'./module': './module.ts',
'components/config': './components/config.ts',
'datasource/module': './datasource/module.ts',
},
output: {
...config.output,
chunkFilename: '[name].bundle.js',
library: 'TencentCloudMonitorGrafanaApp',
},
plugins: [
...config.plugins,
...(options.production ? [new CleanWebpackPlugin()] : []),
new DefinePlugin({
'process.env.TENCENT_CLOUD_MONITOR_GRAFANA_PLUGIN_VERSION': JSON.stringify(packageinfo.version),
}),
new CopyWebpackPlugin(
[
// If src/README.en-US.md exists use it; otherwise the root README
{ from: hasEngREADME ? 'README.en-US.md' : '../README.en-US.md', to: './README.md', force: true },
],
{
logLevel: options.watch ? 'silent' : 'warn',
}
),
],
};
return customWebpackConfig;
};