-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (32 loc) · 756 Bytes
/
index.js
File metadata and controls
34 lines (32 loc) · 756 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
30
31
32
33
34
'use strict'
const { getOptions } = require('loader-utils')
const validateOptions = require('schema-utils')
const schema = {
type: 'object',
properties: {
start: {
type: 'string',
},
end: {
type: 'string',
},
},
}
module.exports = function WebpackRemoveLoader(code) {
const opts = getOptions(this)
validateOptions(schema, opts, {
name: 'Remove Loader',
baseDataPath: 'options'
})
const callback = this.async()
let start
while ((start = code.indexOf(opts.start)) !== -1) {
const pos = code.indexOf(opts.end)
if (pos !== -1) {
code = code.slice(0, start) + code.slice(pos + opts.end.length)
} else {
start = -1
}
}
callback(null, code)
}