forked from JetBrains/ring-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
115 lines (98 loc) · 2.24 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const path = require('path');
const componentsPath = [path.join(__dirname, 'components')];
function resolveLoader(loader) {
return require.resolve(`${loader}-loader`);
}
function loadersObjectToArray(loaders) {
return Object.keys(loaders).map(name => loaders[name]);
}
const htmlLoaderOptions = `?${JSON.stringify({
interpolate: true,
collapseBooleanAttributes: false,
attrs: 'rg-icon:glyph',
root: require('@jetbrains/icons')
})}`;
const svgSpriteLoader = {
test: /\.svg$/,
loader: resolveLoader('svg-sprite'),
include: [require('@jetbrains/logos'), require('@jetbrains/icons')],
options: {
extract: false,
runtimeCompat: true,
esModule: false
}
};
const svgLoader = {
test: /\.svg$/,
loader: `${resolveLoader('url')}?limit=10000`,
include: componentsPath
};
const scssLoader = {
test: /\.scss$/,
include: componentsPath,
use: [
resolveLoader('style'),
resolveLoader('css'),
resolveLoader('postcss'),
`${resolveLoader('sass')}?outputStyle=expanded`
]
};
const cssLoader = {
test: /\.css$/,
include: componentsPath,
use: [
resolveLoader('style'),
`${resolveLoader('css')}?modules&importLoaders=1&localIdentName=[local]_[hash:3]')`,
resolveLoader('postcss')
]
};
const externalCssLoader = {
test: /\.css$/,
include: [
path.dirname(require.resolve('highlight.js/package.json'))
],
use: [
resolveLoader('style'),
resolveLoader('css')
]
};
const babelLoader = {
test: /\.js$/,
include: componentsPath,
loader: `${resolveLoader('babel')}?cacheDirectory`
};
const whatwgLoader = {
test: require.resolve('whatwg-fetch'),
loader: `${resolveLoader('imports')}?Promise=core-js/es6/promise`
};
const htmlLoader = {
test: /-ng(\\|\/)\S*(-ng|-ng__)\S*\.html$/,
include: componentsPath,
loader: resolveLoader('html') + htmlLoaderOptions
};
const gifLoader = {
test: /\.gif$/,
include: componentsPath,
loader: resolveLoader('url')
};
const loaders = {
svgSpriteLoader,
svgLoader,
cssLoader,
externalCssLoader,
scssLoader,
babelLoader,
whatwgLoader,
htmlLoader,
gifLoader
};
// Minimal config for building components
module.exports = {
config: {
module: {
rules: loadersObjectToArray(loaders)
}
},
componentsPath,
loaders
};