-
Notifications
You must be signed in to change notification settings - Fork 31
/
webpack-isomorphic-tools.js
79 lines (72 loc) · 2.11 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
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
var path = require('path')
var webpack_isomorphic_tools_plugin = require('webpack-isomorphic-tools/plugin')
var configuration = require('../../code/configuration').default
module.exports =
{
// debug: true,
// Serves `webpack-assets.json` from memory (bypassing disk)
// in development mode.
// (it is recommended to turn this setting on)
port: configuration.development.webpack.isomorphic_tools.port,
webpack_assets_file_path : './build/webpack-assets.json',
webpack_stats_file_path : './build/webpack-stats.json',
assets:
{
images:
{
extensions:
[
'png',
'jpg',
'gif',
'ico'
]
},
svg:
{
extension: 'svg',
runtime: true
},
markdown:
{
extension: 'md'
},
fonts:
{
extensions: ['woff', 'woff2', 'eot', 'ttf']
},
styles:
{
extension: 'scss',
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 its `module.exports` a little.
parser: webpack_isomorphic_tools_plugin.css_loader_parser
}
}
}