-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack-isomorphic-tools.js
46 lines (44 loc) · 1.32 KB
/
webpack-isomorphic-tools.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
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
// see this link for more info on what all of this means
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
module.exports = {
webpack_assets_file_path: 'webpack-stats.json',
assets: {
images: {
extensions: [
'jpeg',
'jpg',
'png',
'gif',
'svg'
],
parser: WebpackIsomorphicToolsPlugin.url_loader_parser
},
style_modules: {
extensions: ['styl'],
filter: function (m, regex) {
return regex.test(m.name);
},
naming: function (m, options, log) {
//find index of '/src' inside the module name, slice it and resolve path
var srcIndex = m.name.indexOf('/src');
var name = '.' + m.name.slice(srcIndex);
if (name) {
// Resolve the e.g.: "C:\" issue on windows
const i = name.indexOf(':');
if (i >= 0) {
name = name.slice(i + 1);
}
}
return name;
},
parser: function (m, options, log) {
if (m.source) {
var regex = options.development ? /exports\.locals = ((.|\n)+);/ : /module\.exports = ((.|\n)+);/;
var match = m.source.match(regex);
return match ? JSON.parse(match[1]) : {};
}
}
}
}
};