-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
88 lines (82 loc) · 1.99 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const {join, resolve, basename} = require('path');
const webpack = require('webpack');
const ringUiWebpackConfig = require('@jetbrains/ring-ui/webpack.config');
const pkg = require('./package.json');
const libraryName = pkg.name;
module.exports = {
mode: 'development',
entry: getComponentsEntryPoints(),
output: {
path: join(__dirname, './dist'),
filename: '[name].js',
library: libraryName,
libraryTarget: 'commonjs',
publicPath: '/dist/'
},
devtool: 'hidden-source-map',
module: {
rules: [
...ringUiWebpackConfig.config.module.rules,
{
test: /\.css$/,
include: [
resolve(__dirname, 'src'),
resolve(__dirname, 'node_modules/cheerio')
],
use: [{
loader: 'style-loader'
}, {
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1
}
}]
},
{
test: /\.js$/,
include: [
resolve(__dirname, 'src')
],
use: {
loader: 'babel-loader',
options: {
presets: [
['@jetbrains/jetbrains', {
useBuiltIns: 'usage'
}]
]
}
}
}]
},
plugins: [
new webpack.BannerPlugin({
raw: true,
test: /\.js$/,
banner: data => {
const chunk = data.chunk;
if (chunk.files.find(filename => /\.*css$/.test(filename))) {
return 'require("./[name].css")';
}
return '/* No CSS companion file found */';
}
})
],
externals: [
'react',
'react-dom',
'prop-types',
/@jetbrains\/ring-ui/,
/hub-dashboard-addons/,
/core-js/
]
};
function getComponentsEntryPoints() {
const allComponentsFolders = require('glob').sync('src/*');
return allComponentsFolders.reduce((entryConfig, folder) => {
const name = basename(folder);
entryConfig[name] = resolve(folder, `${name}.js`);
return entryConfig;
}, {});
}