forked from steemit/condenser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack-isotools-config.js
72 lines (68 loc) · 3.2 KB
/
webpack-isotools-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
const webpack_isomorphic_tools_plugin = require('webpack-isomorphic-tools/plugin');
const path = require('path');
const ROOT = path.join(__dirname, '..');
module.exports = {
webpack_assets_file_path: ROOT + (process.env.NODE_ENV === 'production' ? '/tmp/webpack-isotools-assets-prod.json' : '/tmp/webpack-isotools-assets-dev.json'),
webpack_stats_file_path: './tmp/webpack-stats.json',
alias: {
assets: path.join(__dirname, '../src/app/assets')
},
assets: {
images:
{
extensions: ['png', 'jpg', 'svg']
},
fonts:
{
extensions: ['woff', 'ttf']
},
styles: {
extensions: ['css', 'scss'],
// which `module`s to parse CSS from:
filter(module, regular_expression, options, log) {
if (options.development) {
// In development mode there's Webpack "style-loader",
// which outputs `module`s with `module.name == asset_path`,
// but those `module`s do not contain CSS text.
//
// The `module`s containing CSS text are
// the ones loaded with Webpack "css-loader".
// (which have kinda weird `module.name`)
//
// Therefore using a non-default `filter` function here.
//
return webpack_isomorphic_tools_plugin.style_loader_filter(module, regular_expression, options, log);
}
// In production mode there will be no CSS text at all
// because all styles will be extracted by Webpack Extract Text Plugin
// into a .css file (as per Webpack configuration).
//
// Therefore in production mode `filter` function always returns non-`true`.
},
// How to correctly transform kinda weird `module.name`
// of the `module` created by Webpack "css-loader"
// into the correct asset path:
path: webpack_isomorphic_tools_plugin.style_loader_path_extractor,
// How to extract these Webpack `module`s' javascript `source` code.
// basically takes `module.source` and modifies `module.exports` a little.
parser: webpack_isomorphic_tools_plugin.css_loader_parser
},
// svg: {
// extension: 'svg',
// parser: webpack_isomorphic_tools_plugin.url_loader_parser
// //parser: function(m, options) {
// // console.log("-- exports.parser -->", m.source);
// // //if (m.source) {
// // // var regex = /module\.exports = "((.|\n)*)"/;
// // // var match = m.source.match(regex);
// // // var r = match ? match[1] : "";
// // // //console.log("-- exports.parser res 0 -->", r);
// // // r = decodeURI(r); //.replace(/"/g,'"');
// // // console.log("-- exports.parser res 1 -->", r);
// // // return r;
// // //}
// // return m.source.replace(/"/g, "'");
// //}
// }
}
};