-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathplugin.js
More file actions
29 lines (24 loc) · 713 Bytes
/
plugin.js
File metadata and controls
29 lines (24 loc) · 713 Bytes
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
var pack = require('./index')
module.exports = function apply (b, opts) {
// When used as a transform
if (typeof b !== 'object') {
throw new Error('browser-pack-flat: must be used as a plugin, not a transform')
}
opts = Object.assign({}, opts || {}, {
raw: true,
debug: opts.debug || b._options.debug,
basedir: b._options.basedir || process.cwd()
})
function addHooks () {
var streams = b.pipeline.get('pack')
var index = streams.indexOf(b._bpack)
streams.splice(index, 1,
pack(Object.assign({}, opts, {
standalone: b._options.standalone,
standaloneModule: b._options.standaloneModule
}))
)
}
addHooks()
b.on('reset', addHooks)
}