-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (21 loc) · 818 Bytes
/
index.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
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
function rewireInlineSourcePlugin (config, env, settings = {}) {
var htmlWebpackPluginIdx = null
var inlinePlugin = new HtmlWebpackInlineSourcePlugin()
// Default settings
settings.inlineSource = settings.inlineSource || '.(js|css)$'
config.plugins.map((plugin, idx) => {
if (plugin.options && plugin.options.template) {
htmlWebpackPluginIdx = idx
plugin.options.inlineSource = settings.inlineSource
}
return plugin
})
if (htmlWebpackPluginIdx === null) {
config.plugins.push(inlinePlugin)
} else {
config.plugins.splice(htmlWebpackPluginIdx + 1, 0, inlinePlugin)
}
return config
}
module.exports = rewireInlineSourcePlugin